• [BizTalk 高级开发技巧]Configuring an outgoing batch


    要在BizTalk中实现对EDI X12文件的批量打包功能,可以按以下步骤配置和开发:

    1)配置Party的X12 Properties>Party as Interchange Receiver>Interchange Batch Creation Settings

          1.1配置Filter criteria

    batch1 

          1.2配置Release criteria 为”External release trigger

          1.3注意:如果一个SendPort要订阅这个Party的Batch Transaction Set就要设置以下订阅条件

          EDI.DestinationPartyName == MyPartA  And
          EDI.ToBeBatched == False

          1.4然后启动就可以了

       2)循环业务数据,对于业务数据生成的每一个Transaction Set,要用Correlation Set在Orchestration中提升如下属性(需要引用两个程序集:

    C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Edi.BaseArtifacts.dll
    C:\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Edi.BatchingOrchestration.dll)

          EDI.DestinationPartyId = Party’s Id

          EDI.ToBeBatched = True

          EDI.EncodingType = 0/1 –0 for EDI X12, 1 for EDI FACT

    然后,Direct Send to MessageBox,最后想办法向表[BizTalkMgmtDb].[dbo].[PAM_Control]写入一条记录(你可以直接操作DB执行INSERT,也可以使用SQL Adapter的updategrams执行INSERT)。为什么要向表[BizTalkMgmtDb].[dbo].[PAM_Control]写入这么一条数据呢?

    INSERT INTO [BizTalkMgmtDb].[dbo].[PAM_Control]
               ([DestinationParty]
               ,[EdiMessageType]
               ,[ActionType]
               ,[ActionDateTime]
               ,[UsedOnce])
         VALUES
               (18

               ,0 --0 for EDI X12, 1 for EDI FACT
               ,’EdiBatchOverride’
               ,GETDATE()
               ,0)

    这是因为BizTalk EDI Application 中的Microsoft.BizTalk.Edi.BatchingOrchestration.BatchingService会在接收到下面这种消息时会对前面Direct Send 到 MessageBox的EDI XML 消息组装成一个包含多个Transaction Set消息,然后可以通过EdiSend发送到FileSystem或者FTP等等。

    PAM Control Message:

    <ControlMessage xmlns="http://sqlcontrolmessage.issueselect"/>
        <PAM_Control>
            <DestinationParty>18</DestinationParty>
            <EdiMessageType>0</EdiMessageType>
            <ActionType>EdiBatchOverride</ActionType>
            <ActionDateTime>[yyyy-mm-ddThh:mms.sss]</ActionDateTime>
            <UsedOnce>0</UsedOnce>
            <ToBeBatched>1</ToBeBatched>
        </PAM_Control>
    </ControlMessage>

           那么,这种消息是如何到MessageBox的呢?它的产生过程是这样的:BizTalk EDI Application 有一个SQL Adapter类型的Receive Location(BatchControlMessageRecvLoc),它默认会30秒执行一下存储过程BizTalkMgmtDb.dbo.edi_GetControlMessage,然后由这个存储过程产生一个ControlMessage 消息,然后经过BatchControlMessageRecvPipeline处理,然后进入MessageBox,然后BizTalk EDI Application 中的Microsoft.BizTalk.Edi.RoutingOrchestration.BatchRoutingService和Microsoft.BizTalk.Edi.BatchingOrchestration.BatchingService在收到这种BatchControlMessage后就会做相应的路由和打包处理。它会将多个EDI XML处理成一个带有IAS,GS等头部信息的EDI Message,然后可以通过一个使用EdiSend Pipeline的SendPort将这个EDI Message处理成X12发送到FileSystem或者FTP等等。这个SendPort需要使用如下订阅条件:

    EDI.DestinationPartyName == MyPartA  And
          EDI.ToBeBatched == False

          如果要接收多个Party的这种Batch EDI Message可以设置多组这种订阅条件!

    参考资料:(1)http://msdn.microsoft.com/en-us/library/bb226357(BTS.20).aspx

    (2)http://blog.biztalk-info.com/archive/2009/01/29/BizTalk_2006_R2_X12_EDI_Batching.aspx

    (3)http://www.biztalkgurus.com/blogs/biztalksyn/archive/2009/05/15/outbound-edi-batching-tutorial.aspx

    Thanks for your reading! This is just my learning note.

  • 相关阅读:
    谷歌阅读器将于2013年7月1日停止服务,博客订阅转移到邮箱
    SelfIntroduction
    WCF(四) Configuration file (配置文件)
    亚当与夏娃的礼物
    WCF(三) Message pattern
    面试小题
    分内分外
    C#多线程处理之AutoResetEvent和ManualResetEvent
    WCF(五) Host WCF Service
    ARX中的Purge
  • 原文地址:https://www.cnblogs.com/fuhongwei041/p/outgoing.html
Copyright © 2020-2023  润新知