Append messages in BizTalk

來源:互聯網
上載者:User

  I had been agonising for a while on how to aggregat sequential messages in to a single message and handle it at a time. And yet I have finally found out the solution, it's easy to accomplish but hard to explain, seems BizTalk team never want to write some internal function for this, what a pity, we will use this in many scenes.

  To begin, I had set up a scene:

  Our partner would like to send us some Order via file transport and the format is simplified xml. Like Order-head and Order-Item. The Order-Head will indicate how many items would come next. We have to handle the Order-Head and all the Order-Items in a batch although they would not come in a time. At the end, we will map the first comes Order-Head and the followed Order-Items into one Order.

  That's what we have to do.

  Knowing this, we would at first thinking the sequential convoy, that's right.

  but what's next? while Order-Items comes one after another, they will appear just a seconds, and when it comes the old one will be overwrited, so we have to combine them into one single. I'm a little disgusted with writting helper code for just a message handle, although I had know it for a long time that bizTalk had never supply such a functorID in the map or the orchestration tools.

  After search a lot in google and MSDN(thanks google and MSDN), I have found that Biztalk had a sample on this topic. Seems BizTalk team had prolepses that we will have trouble on this.

  Ok, see what I have done.

  At 1st, define the schema.

  Order-Head, with promote OrderID distinguished and ItemsCount to property fileds.

      Order-Item, with promote OrderID distinguished and ItemsID to property fileds. 

  

  The Order-envelope, will be used in a sendpipeline, the schema is envelope type and note that the node "OrderEnvelope" has a body_xpath directed to the Items node.

  2nd, we have to design a sendpipeline.

  Drag a XML assemble to the Assemble, set up the Envelope schemas to Order-envelope and Document-schemas to Order-Item in its properties window. This is what we will use for to do the message appending, it will be executed from orchextration to assemble collected messages into an XML interchange.

  3rd, write a orchestration to do the whole thing.

  

  (I'm not going to say more about the sequential convoy, you can find many samples.)

  And the orchestration properties like below:

  
the Message MsgAggregated is a System.xml.xmldocument
the Variables MessagesToAggregate is knid of Microsoft.XLANGs.Pipeline.SendPipelineInputMessages
the Variables countOrderItem will be used for the loop count so it's int

  In Expression_1, I write :

    CountOrderItem = MsgOrderHead.ItemsCount;

  In Expression_2, I write :

    CountOrderItem = CountOrderItem - 1;
    MessagesToAggregate.Add(MsgOrderItem);

  In MessageAssign shape, I write:

    MsgAggregated = null;
    Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(

      typeof(AggregatorMsg_SendPipeline), MessagesToAggregate, MsgAggregated);

  And then I send this constructed MsgAggregated out to a folder.

  After that, I build and deployed the project and did some test.

  

  The output is like below:

  

  Ok, we have got all the Order-Items into one envelope, what we have to do next is simple, assign this message to a organised schema, and do a mutil input message message to map the Order-Head and Order-Item into what you want.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.