简体   繁体   English

Windows Workflow Foundation本地托管和Web Api

[英]Windows Workflow Foundation On-Premise Hosting and Web Api

I want to use Windows Workflow Foundation 4.5 and trigger the workflows via web api. 我想使用Windows Workflow Foundation 4.5并通过Web API触发工作流。 What are my hosting options now that MS is ending AppFabric support? 既然MS终止了AppFabric支持,我现在有哪些托管选项? Should I even use Windows Workflow Foundation or should I look into a 3rd party solution? 我应该使用Windows Workflow Foundation还是应该寻找第三方解决方案?

This is on-premise and I don't have the ability to use azure. 这是前提,我没有使用天蓝色的能力。 I've done a few workflows and seems like WWF isn't hard to use but it's not clear how to host it. 我已经完成了一些工作流程,似乎WWF并不难使用,但尚不清楚如何托管它。 Can I host inside a web api project without AppFabric? 我可以在没有AppFabric的情况下在Web api项目中托管吗?

My main concern is being able to resume workflows if IIS app pools recycle using WorkflowApplication or the server crashes. 我主要关心的是,如果IIS应用程序池使用WorkflowApplication回收或服务器崩溃,是否能够恢复工作流。 I'm not using WCF I plan to use WorkflowApplication inside the web api. 我没有使用WCF,我打算在Web api中使用WorkflowApplication。

Can anyone point me in the right direction on implementing the custom features that AppFabric was responsible for? 谁能为我指出实施AppFabric负责的自定义功能的正确方向? Resuming, Logging, etc.. 恢复,记录等。

From MS: Using IIS with AppFabric is the preferred host for workflows. 来自MS的信息:将IIS与AppFabric一起使用是工作流的首选主机。 The host application for workflows using AppFabric is Windows Activation Service, which removes the dependency on HTTP over IIS alone 使用AppFabric的工作流的主机应用程序是Windows Activation Service,它可以消除对IIS上HTTP的依赖

IIS 7.0 recycles application pools periodically for various reasons. IIS 7.0出于各种原因会定期回收应用程序池。 When an application pool is recycled, IIS stops accepting messages to the old pool, and instantiates a new application pool to accept new requests. 回收应用程序池后,IIS停止接受到旧池的消息,并实例化一个新的应用程序池以接受新请求。 If a workflow continues working after sending a response, IIS 7.0 will not be aware of the work being done, and may recycle the hosting application pool. 如果工作流在发送响应后继续工作,则IIS 7.0将不知道正在完成的工作,并且可能回收托管应用程序池。 If this happens, the workflow will abort, and tracking services will record a 1004 - WorkflowInstanceAborted message with an empty Reason field. 如果发生这种情况,工作流将中止,并且跟踪服务将记录1004-WorkflowInstanceAborted消息,其中的原因字段为空。

If persistence is used, the host must explicitly restart aborted instances from the last persistence point. 如果使用持久性,则主机必须从上一个持久性点显式重新启动中止的实例。

If AppFabric is used, the workflow management service will eventually resume the workflow from the last successful persistence point if persistence is used. 如果使用AppFabric,则工作流管理服务将在使用持久性的情况下最终从上一个成功的持久性点恢复工作流。 If no persistence is used, and the workflow performs operations outside a Request/Response pattern, data will be lost when the workflow aborts. 如果不使用持久性,并且工作流在请求/响应模式之外执行操作,则工作流中止时数据将丢失。

One hosting strategy is to have your Web API methods simply put messages into a queue (like MSMQ or Rabbit MQ), and have a back-end Windows Service for actually hosting the workflow instances. 一种托管策略是让您的Web API方法将消息简单地放入队列(例如MSMQ或Rabbit MQ),并具有用于实际托管工作流实例的后端Windows Service。 The back-end service would continuously read the queue(s) and spin up the correct workflow you need. 后端服务将连续读取队列并启动所需的正确工作流程。

This way you don't run into IIS application pool recycling events that could terminate a workflow. 这样,您就不会遇到可能终止工作流的IIS应用程序池回收事件。

If you need to have a Web API method wait for the workflow to finish, you could have it wait for a "correlation message" to arrive on the queue to signal that the operation finished. 如果需要让Web API方法等待工作流完成,则可以让它等待“相关消息”到达队列以表示操作已完成。 Or you could store the WF instance result in a DB table. 或者,您可以将WF实例结果存储在数据库表中。

I actually recommend not using App Fabric and simply rolling your own hosting service for better flexibility. 我实际上建议不要使用App Fabric,而只是滚动自己的托管服务以提高灵活性。 Plus its relatively simple to implement one with your desired behaviors. 加上它相对简单,即可实现您所需的行为。

Here's a diagram I hope that will help out in your design or give ideas: 这是一个希望对您的设计有所帮助或给出想法的图表:

粗略的图表...但可能会有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM