zoukankan      html  css  js  c++  java
  • Append messages in BizTalk

      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.

  • 相关阅读:
    Zero-Copy&sendfile浅析
    Redis数据清除问题
    Redis官方文档》持久化
    GNU C 、ANSI C、标准C、标准c++区别和联系
    有关jQuery valid 验证多个同name属性的input的问题
    jQuery validator 增加多个模板
    archiver error. Connect internal only, until freed. 之解决办法
    链接ftp,把文件或图片上传到ftp指定的文件夹中
    java 数字金额转换中文金额
    java工具类 --千分位方法
  • 原文地址:https://www.cnblogs.com/JasonLiao/p/1913917.html
Copyright © 2011-2022 走看看