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.

  • 相关阅读:
    IIs和ftp
    java中HashMap重要性质和优化总结
    深入理解mysql的left join(真的很深入)
    windows bat批处理语法简析
    遍历hashMap的两种方式
    Java开发实践 集合框架 全面分析
    MySQL中日期与时间类型
    CentOS6.5下Redis安装与配置
    查看redis进程
    Web阶段:第七章:Tomcat服务器
  • 原文地址:https://www.cnblogs.com/JasonLiao/p/1913917.html
Copyright © 2011-2022 走看看