Calling the BRE Remotely from .NET

It seems that the BRE comes up a lot in my work with BizTalk these days, which is why I’ve written some articles about its use.  In one article, I discuss how to call the BRE from .NET. The code in this article works very well when calling a local BRE installation, but we don’t address how to achieve the same goal when calling an instance of the BRE on another server. One ETM reader asked me about this (thanks, Gautam) which led me to an MSDN post by K Kanavia:

The approach in the article is to more explicitly use pieces of the BRE API that identify the server rather than to accept the default which is to use the local engine. This approach is detailed in the code below:

//Get the SqlRuleStore from BizTalkRuleEngineDb database on remote m/c
//pass on correct databaseserver and database name
Microsoft.RuleEngine.RuleSetDeploymentDriver rdd =
    new RuleSetDeploymentDriver(RuleEngineDatabaseServer,

SqlRuleStore sqlRuleStore =
    (SqlRuleStore) rdd.GetRuleStore();

//Get access to RuleSetInfoCollection for the policy,
//pass on the policy name
RuleSetInfoCollection rsic = sqlRuleStore.GetRuleSets(policyName,

//Create a RuleSet object based on the rule set information
RuleSet rs = sqlRuleStore.GetRuleSet(rsic[0]);

//Create the RuleEngine object
engine = new RuleEngine(rs);

//create facts here
Object[] facts = ;

//if u want to catch the debug info from MS BRE execution.
if (debugRulesEngine)
    dti = new DebugTrackingInterceptor(@rulesEngineDebugFile);
    engine.TrackingInterceptor = dti;

//Execute the policy by invoking RuleEngine.Execute method,
//passing on the facts

Thanks to K Kanavia for posting this code on MSDN!

About Ed Jones

Ed is a .NET and Integration architect for Avanade in the Twin Cities. Contact Ed

What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: