【问题标题】:BizTalk manually fetch file instead of pollingBizTalk 手动获取文件而不是轮询
【发布时间】:2012-02-11 20:54:06
【问题描述】:

我想知道是否有一种方法可以将 BizTalk 配置为具有不会不断轮询文件夹以查找文件,而是“按需”检查文件的编排。

“按需”是指我需要 BizTalk “等待”网络服务调用(通过 WCF 端口),然后在 FTP 文件夹中获取文件并启动编排。

这是可行的吗?我读到“动态端口”可以用于此,是真的吗?

谢谢, 亚历克斯

【问题讨论】:

    标签: biztalk


    【解决方案1】:

    您可以在 WCF 接收端口激活的业务流程中动态创建 FILE(或 FTP)接收位置。

    Brian Loesgen blogged 一个简单的代码示例,您的业务流程可以调用它来创建接收位置。如果服务器和文件夹名称从一个调用到下一个调用没有变化,那么您可以每次使用相同的接收位置,并在运行时激活/停用它。

    这是另一个 Stack Overflow 问题,专门解决在代码中激活接收位置的问题:Is there a way to automate turning a BizTalk Receive Location on or off through code? 在 Visual Studio 中创建一个新的类项目,添加对 Microsoft.BizTalk.ExplorerOM 的引用,编写几行代码,你就得到了你的帮助程序集!

    这是一个示例from MSDN,用于创建和配置 HTTP 接收位置:

    private void CreateAndConfigureReceiveLocation()
    {
       BtsCatalogExplorer root = new BtsCatalogExplorer();
       try
       {
          root.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";
    
          //First, create a new one way receive port.
          ReceivePort myreceivePort = root.AddNewReceivePort(false);
    
          //Note that if you dont set the name property for the receieve port, 
          //it will create a new receive location and add it to the receive       //port.
          myreceivePort.Name = "My Receive Port";
    
          //Create a new receive location and add it to the receive port
          ReceiveLocation myreceiveLocation = myreceivePort.AddNewReceiveLocation();
    
          foreach(ReceiveHandler handler in root.ReceiveHandlers)
          {
             if(handler.TransportType.Name == "HTTP")
             {
                myreceiveLocation.ReceiveHandler = handler;
                break;
             }
          }
    
          //Associate a transport protocol and URI with the receive location.
          foreach (ProtocolType protocol in root.ProtocolTypes)
          {
             if(protocol.Name == "HTTP")
             {
                myreceiveLocation.TransportType =  protocol;
                break;
             }
          }
    
          myreceiveLocation.Address = "/home";
          //Assign the first receive pipeline found to process the message.
          foreach(Pipeline pipeline in root.Pipelines)
          {
             if(pipeline.Type == PipelineType.Receive)
             {
                myreceiveLocation.ReceivePipeline = pipeline;
                break;
             }
          }
    
          //Enable the receive location.
          myreceiveLocation.Enable = true;
          myreceiveLocation.FragmentMessages = Fragmentation.Yes;//optional property
          myreceiveLocation.ServiceWindowEnabled = false; //optional property
    
          //Try to commit the changes made so far. If the commit fails, 
          //roll-back all changes.
          root.SaveChanges();
       }
       catch(Exception e)
       {
          root.DiscardChanges();
          throw e;
       }
    }
    

    【讨论】:

      【解决方案2】:

      不幸的是,BizTalk 唯一为此提供的东西是一种称为服务窗口的东西,它允许您安排接收位置的打开和关闭。

      但是它的限制非常严格,每 24 小时只有一个窗口。您还必须提前知道时间。

      动态端口仅适用于发送消息,不适用于接收消息。

      【讨论】:

        【解决方案3】:

        如果您以任何方式控制 Web 服务,那么您始终可以使用队列或数据库表松散耦合两个系统,即更改 Web 服务,以便在进行调用时,将 BizTalk 的消息放置在一个队列/桌子。然后将您的编排连接到同一个队列/表,以便它“按需”获取文件。这种情况可能并不完全适合您的情况,但这可能是您能得到的最接近的情况......

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-08-03
          • 2021-12-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多