BizTalk 手动获取文件而不是轮询

发布于 2024-12-27 08:49:10 字数 192 浏览 1 评论 0原文

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

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

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

谢谢, 亚历克斯

I would like to know if there's a way to configure BizTalk to have an orchestration that wouldn't constantly poll a folder for a file, but would rather check for a file "on-demand".

By "on-demand", I mean that I need BizTalk to "wait" for a web service call (via WCF port) and then go fetch a file in an FTP folder and start the orchestration.

Is it something feasible? I read that "Dynamic ports" could be used for that, is it true?

Thanks,
Alex

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鲜肉鲜肉永远不皱 2025-01-03 08:49:10

您可以在由 WCF 接收端口激活的编排中动态创建 FILE(或 FTP)接收位置。

Brian Loesgen 博客一个简单的代码示例您的编排可以调用它来创建接收位置。如果服务器和文件夹名称从一次调用到下一次调用都没有更改,那么您每次都可以使用相同的接收位置,只需在运行时激活/停用它即可。

这是另一个 Stack Overflow 问题,专门解决了在代码中激活接收位置的问题:有没有办法通过代码自动打开或关闭 BizTalk 接收位置?
在 Visual Studio 中创建一个新的类项目,添加对 Microsoft.BizTalk.ExplorerOM 的引用,编写几行代码,您就得到了帮助程序集!

以下是来自 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;
   }
}

You could dynamically create a FILE (or FTP) receive location in an orchestration that is activated by the WCF Receive Port.

Brian Loesgen blogged a simple example of code that could be called by your orchestration to create receive locations. If the server and folder names do not change from one call to the next, then you could use the same receive location each time and just activate/deactivate it at run-time.

Here is another Stack Overflow question that specifically addresses activating a receive location in code: Is there a way to automate turning a BizTalk Receive Location on or off through code?
Create a new class project in Visual Studio, add in a reference to Microsoft.BizTalk.ExplorerOM, write a few lines of code, and you've got your helper assembly!

Here's a sample from MSDN to create and configure an HTTP receive location:

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;
   }
}
蹲墙角沉默 2025-01-03 08:49:10

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

然而,它的限制非常严格,每 24 小时内只有一个窗口。您还必须提前了解时间。

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

Unfortunately the only thing BizTalk provides for this is something called a service window which allows you to schedule receive locations to turn on and off.

However it's very restrictive, with a single window per 24 hour period only. Also you have to know the times upfront.

Dynamic ports only apply to the send of messages, not for receiving them.

无边思念无边月 2025-01-03 08:49:10

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

If you control the web service in any way, then you can always loosely couple the two systems using a queue or a database table, i.e. change the web service so that when a call is made, a message for BizTalk is placed in a queue/table. Then hook up your orchestration to the same queue/table so that it fetches a file "on demand". This scenario may not be entirely appropriate in your situation, but that's probably the closest you can get...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文