BizTalk Dynamic Brokering Message Sample

This solution is a very simple Dynamic Broker message but uses a lot of interesting BizTalk Server aspects.
Project
You can extend this idea for more complex BizTalk Server dynamic brokering solution.
In order to resolve this problem I used only BizTalk artifacts, in this case I have thought to use BRE, Business Rule Engine, that I consider to be the more interesting part to use to create a BizTalk solution based on dynamic rules.
How it works.
This example offers the possibility to send any type of information, from any type of source, simply defining the entity source and its rules of shipment dynamically.
The message is received by the receive location, this BizTalk port uses a pipeline of pass-through in order receiving any type of information, this pipeline set a property named DESTINATION, this property defines the name of the policy that will set up all the parameters of shipment.

schemadestination
In order to promote the property I have used the custom pipeline component named PropertyPromotionComponent, you can download this component in Codeplex to this address, if you prefer you can develop your own component
pipeline

Inside BRE I have defined the policy named FILE, that takes care to set up the shipment parameters, in this case I set a simple parameter,
bre

In this case the rule is always true but we can extend as we prefer and this rule set the value of BaseTypeAddress field with the destination path.
I have created an orchestration that receives the messages and it takes care to set up the properties of the dynamic port, clearly we can use the same principle to change al behaviors of our process in the orchestration.

orchestration

The important aspect is to call the BRE Policy dynamically, in this way we will be totally open to extend the solution.

Here the code that I have used in order to call the rule.
cde

The rule pass the message used by the orchestration to set all of its behaviors and artifact, in this case only the dynamic port.

schemaproperties

This example is very simple but it present the idea to create a dynamic brokering message system using a pure BizTalk Server solution.
You can use this sample and extend the idea for any type of BizTalk dynamic solutions.

You can download the sample here.

About these ads

10 comments

  1. mak

    Hello nino

    i have flat file, it contains more than 10,000 records, i used receive pipe line decode stage (custom pipe line to update the flat file name) and flat file disassemble to disassemble the message.

    Question, end of the last line in the flat file or last message, i want to call custom .net code to generate pdf report and send to email.
    I am new for BizTalk, my orchestrations are like , port to receive -> receive message -> insert record -> if i put send message here, it is creating 10,000 pdfs and emails.

    I created send custom pipeline message, encode stage is calling the custom .net code.

    I don’t know how do i find our last one or execute only one time at the end of the flat file process?

    thanks
    Mak

    • ninocrudele

      I Mak,
      don’t make send operation or same stuff fro a pipeline internally, this is wrong, because you work out of a BizTalk concept and control.
      Organize the solution in different subscriber processes, one for the debatch and one to send the email
      don’t send messages from BizTalk using c# coding because you will be out of the scope of BizTalk Server
      Let me know

      • mak

        May be i am not mentioned it clearly. My .net code will create PDF report and attached to email. so i want to call this function at the end of flat file process (like end of 10000th line). Qns How do i know which is last transaction to kickstart the PDF generation function?

      • mak

        i did it this way, i got total record in the decode pipeline stage, then promote to inmsg.Context.Promote(“TotalRecord”, propertySchema, count); , then i wrote .net helper function to increment the record number (static) and check the record number is equal to total record. if it is same then i call ssrs report and send to email.

  2. Suleiman Shakhtour

    Hi Nino,
    Thank you for sharing this post.
    I think there is not a way to use a totally dynamic broker using a pure BizTalk Server solution.
    Your provided solution will work in case it is only file endpoint with different address locations but what about other adapters ftp,sftp,,,,etc?
    What if each destination use different adapter?
    How it will be handled with a pure BizTalk Server Solution?
    You have to have something like ESB Toolkits.
    Regards,
    Suleiman shakhtour

    • ninocrudele

      Hi, good question, there are some different approaches, .Net, Reflection and Abstraction, injection, all of them applicable in a lot of different place, pipeline, map,bre,orchestration.
      This will be one of the topics in BizTalk Summit 2014 London http://www.biztalk360.com/BizTalk-Summit-2014/index.html , for me the ESB Toolkit is a pure BizTalk solution (I call them T-ready ), ready to create a ESB concept BTS solution in more simple mode, but we could create all of this with our hands without any problem.

  3. mak

    i did it this way, i got total record in the decode pipeline stage, then promote to inmsg.Context.Promote(“TotalRecord”, propertySchema, count); , then i wrote .net helper function to increment the record number (static) and check the record number is equal to total record. if it is same then i call ssrs report and send to email.

    • ninocrudele

      Hi Fernando, we can use, we must to use, the BRE everywhere in BizTalk, some places are better than other, the pipeline component is one of the most critical place in BizTalk, for a lot of reasons,, but if you prefer you can do the same everywhere in BizTalk, in mapping too :)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s