locked
How to aggregate multiple messages to one which are related to one single message RRS feed

  • Question

  • I'm not sure its a good architectural pattern or not, Assume we have a database table with columns like

    messageid, message part, message.  The message column has a size limit of 128KB and so the source system will split the messages into multiple chunks as per e.g and store here.

    e.g data

    1 , 1/4, messagepart1

    1, 2/4, messagepart2

    1.3/4, messagepart3

    1,4/4, messagepart4

    Single messageparts doesn't confine to any schemas (its just like string), once we aggregate all the messageparts then the aggregated message will be confined to valid schema for future processing.

    What would be the best way to implement this in BizTalk. Can someone please help me on this. Thanks you very much for your help in advance.


    Sunday, December 14, 2014 3:44 AM

Answers

  • Since you didn't mention specifically how the chunks will be received, I'll assume SQL Server or Oracle and you can Poll them out.  So:

    1. Stored Procedure to retrieve the chunks order by part number, ascending.
    2. Create a Schema for the message using the WCF Schema Wizard.
    3. Write a custom Pipeline Component for the Decode Stage that reads though the result and writes the value of each message field to a new BizTalk Message.
    4. Process the message normally.

    • Marked as answer by Angie Xu Wednesday, January 7, 2015 11:58 AM
    Monday, December 15, 2014 4:01 AM
    Moderator

All replies

  • Best way you can use you can have a helper class which can add parts to a multi part message .Construct the Message in loop with the counter of MessagePart.

    Some thing like below

    public class AddMessageParts
    {
         public static void AddPart(XLANGMessage message, object part, String partName)
         {
              message.AddPart(part, partName);
         }
    }

    There are three overloaded methods for Microsoft.XLANGs.BaseTypes.AddPart:

    public void AddPart(object part, String partName);
    public void AddPart(XLANGPart part);
    public void AddPart(XLANGPart part, String partName);


    In your BizTalk project, add a reference to the public class and call the AddPart method from the Expression shape in your orchestration as follows:

    AddMessageParts.AddPart(myMessage, myStringObject, “StringObject1”);

    For Reference you can have below blogs :

    How to Use Expressions to Perform Message Assignments

    Unleashing the Power of BizTalk Multipart Messages in BizTalk Server

    Pass an XLANG message or an XLANG message part to a .Net method call as a parameter in Orchestration. / Call .Net assembly to update the XLangMessage from Orchestration.

    Thanks

    Abhishek

    Sunday, December 14, 2014 6:36 AM
  • What I understood from you is you are already getting your messages inside database and need to create a message based different chunks of xmls.
    I would suggest an orchestration which will loop through all messages (count of database records per messageid) and construct the aggregated message. You can refer Aggregation sample provided with BizTalk SDK samples which has loop for 2 messages and uses send pipeline to aggregate for your reference. Since you have messages in database, you can use use wcf-sql adapter to read data and generate schema as per table structure. You can then choose options to convert string message to xml and using c# and assign to the final message. 

    If this answers your question please mark it as Answer and if this post is helpful, please vote as helpful. Thanks !

    Sunday, December 14, 2014 9:12 AM
  • Since you didn't mention specifically how the chunks will be received, I'll assume SQL Server or Oracle and you can Poll them out.  So:

    1. Stored Procedure to retrieve the chunks order by part number, ascending.
    2. Create a Schema for the message using the WCF Schema Wizard.
    3. Write a custom Pipeline Component for the Decode Stage that reads though the result and writes the value of each message field to a new BizTalk Message.
    4. Process the message normally.

    • Marked as answer by Angie Xu Wednesday, January 7, 2015 11:58 AM
    Monday, December 15, 2014 4:01 AM
    Moderator