Martijn's blog - E-Commerce, EAI, BizTalk and .NET


Microsoft Business Rules Engine (MS-BRE) - XmlTrackingInterceptor

A lot of businesses have a need to prove what their software has done in evaluating certain requests from customers, such as loan applications, mortgage application, etc. Using the BRE, there's a few ways to accomplish this goal.

One of them is implementing an interface called the IRuleSetTrackingInterceptor. Implementing this interface consists of writing code for the following methods, then called by the BRE as it's executing a RuleSet:

  • SetTrackingConfig
    Sets the rule set tracking GUID and tracking configuration.
  • TrackAgendaUpdate
    Tracks updates to the rule engine agenda.
  • TrackConditionEvaluation
    Tracks the evaluation of rule conditions.
  • TrackFactActivity
    Tracks changes to working memory.
  • TrackRuleFiring
    Tracks the firing of a rule.
  • TrackRuleSetEngineAssociation
    Tracks the association of a rule set with a rule engine instance.
Once your custom implementation is done, you can associate the class with a RuleSet to be tracked by passing it from code when calling Policy.Execute, e.g.:
Policy executingPolicy = new Policy("My Policy", 1, 4);
executingPolicy.Execute((object[]) facts.ToArray(typeof(object)), interceptor);

After the BRE is done executing the specified Policy, the interceptor class has been called for each task and might contain valueable information as to the execution of the Policy.

The BRE supplies a standard implementation of IRuleSetTrackingInterceptor, called the DebugTrackingInterceptor. This interceptor is also used if you have any "Call Rules" shapes within your Orchestrations. It's the way for the HAT to enable viewing what went on within the business process, BRE wise.

The DebugTrackingInterceptor, however, uses a plain text file format, which can be cumbersome to parse using tools. I've implemented a Xml version, which can be downloaded here. Using it you can track the same information as the DebugTrackingInterceptor does, but in a Xml format.


Tool update: Policy Exporter

When working with the BRE, the stringent way the Business Rule Composer manages versioning can be a real pain. Undeploying / unpublishing policies and/or unpublishing vocabularies can be very handy. This tool allows you to:

  • Import multiple exported items at once
  • Delete multiple policies / vocabularies at once
  • Export multiple policies / vocabularies at once
  • Undeploy policies
  • Unpublish policies / vocabularies
Ofcourse, one should not use this tool in a production environment, as the versioning itself has a valid purpose. The tool is meant to ease development.

I previously published this tool under the name "Policy Exporter". This is an update to that tool and a name change to better reflect it's purpose. It's now called "BRE Policy and Vocabulary manager" (what's in a name ;-) ) and it's current version is 1.1.

The tool itself, including full sourcecode, can be downloaded from this location.

A scenario example

While developing a Policy, you need a Vocabulary item added to the Vocabulary used in the current Policy:
  1. Save the Policy.
  2. Unpublish the Vocabulary using the tool
  3. Press F5 in the Business Rule Composer
  4. Ammend the Vocabulary
  5. Publish the Vocabulary
  6. Press F5 once again
  7. Use the new item within the Policy



I've been awarded the Microsoft Most Valuable Professional (MVP) Award again! Thanks to everyone who asked me questions or help this year ;-)


FWD: Retrieving context properties within a map

OK, first off, I'm not sure if you really want this, but people are asking for it a lot and I ran across a solution, so read this article if you want to retrieve a context property for the current message within the mapper (using a custom functoid).