Business Rules Engine implementation to Message Flow

At this post I want to show how you can use message routing with BRE (Business Rules Engine)
It will allow information workes, analysts and admins to change routing condition values without
code changes, recompilations and downtime.

Scenario:
Message will be taken from a folder. Checked if value is greater than 1000 it will be moved to folder BIG, else it will be moved to folder small. Then Admin will change value to 2000 from BRE without code recompiling and downtime.

Lets first create BizTalk Project in Visual Studio


Then I will create Order Schema


Then will create 2 new elements: OrderID(string), VIP (boolean) and Amount(integer)
VIP field will be use to identify VIP order, which will be changed by BRE
Also if should be Distinguished field



Then create Routing orchestration
where I will use just created Schema as input and output type.

Create new Message with new OrderSchema type, Receive and Send Shapes.
Create Receive port and assign it to receive shape
Create Send port and assign it to Send shape



Build the Solution to check if there is everything OK.

Now open BRE




Create new Policy - RouteRule
And import schema from BizTalk Project


Add 2 Rules to RouteRule
One for Amount >= 1000 and Amount <1000
Then on right panel you will see Conditions option
Right click on Conditions and add Predicate Greater Than Equal for one rule
and Less then for another rule

Drug and drop from imported schema Amount to Argument1 and write 1000 in argument 2

To Action (lower panel) drug and drop VIP,
for Rule1 it should become True and False for second Rule

Click On Save
Right Click On Version 1.0 and click Publish
When Policy will be published you will not be able to change it.
So you will need to create new Version for new routing Values
Now open BRE Deployment Wizard, which will publish Policy to BizTalk Server
then the policy will be available for your Orchestration


Select Deploy Policy click Next
Select Database and SQL Server click Next
Select your Rule from list click Next and Next to finish

In your orchstration find CallRules from Toolbox and drug it after Receive Shape
In Configuration Select your Rule
for Parameter Select your message


Now your Orchestration will look like


Create new Decide Shape where you can check VIP parameter
So if VIP == true , you can send it to one folder, and if VIP != true you can send it to another folder


Comments

Popular posts from this blog

How to poll database using WCF-SQL adapter

SQL query timeout from application but works fast from SSMS