7.7. Tracking Interceptor

When developing and debugging rules, it can sometimes be difficult to understand why the BRE is behaving in the way it is. A Tracking Interceptor enables you to understand exactly what the BRE is doing when executing your rules.

Unfortunately, a custom Tracking Interceptor cannot be configured unless you invoke the BRE directly, which therefore precludes the use of the Call Rules shape. You should consider invoking the BRE directly via .NET code, as covered in the "Invoking Rules" section of this chapter.

The interceptor is incredibly useful for figuring out what the rules engine is doing and why. In my view, you should use it on all BRE projects. It will save you a significant amount of time and hassle.

7.7.1. DebugTrackingInterceptor

A DebugTrackingInterceptor ships with the BRE and is located in the standard Microsoft.RuleEngine namespace. This Tracking Interceptor can log tracking information to a text file on disk only.

To make use of the interceptor,you must first initialize the interceptor as shown here by passing a filename for trace output to be written to:

DebugTrackingInterceptor interceptor = new
DebugTrackingInterceptor("TrackingOutput.txt");

You must then configure the BRE to make use of the interceptor by passing it as a parameter to the Policy.Execute method, as follows:

DebugTrackingInterceptor Interceptor = new DebugTrackingInterceptor("output.txt");
Policy Policy = new Policy("Policy1");
Policy.Execute(Facts,Interceptor);

Once configured ...

Get Professional BizTalk® Server 2006 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.