Windows Workflow Foundation 本地托管和 Web Api [英] Windows Workflow Foundation On-Premise Hosting and Web Api

查看:25
本文介绍了Windows Workflow Foundation 本地托管和 Web Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Windows Workflow Foundation 4.5 并通过 web api 触发工作流.MS 终止对 AppFabric 的支持后,我的托管选项有哪些?我应该使用 Windows Workflow Foundation 还是应该研究第三方解决方案?

I want to use Windows Workflow Foundation 4.5 and trigger the workflows via web api. What are my hosting options now that MS is ending AppFabric support? Should I even use Windows Workflow Foundation or should I look into a 3rd party solution?

这是内部部署,我无法使用 azure.我已经完成了一些工作流程,看起来 WWF 并不难使用,但不清楚如何托管它.我可以在没有 AppFabric 的情况下托管在 web api 项目中吗?

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. Can I host inside a web api project without AppFabric?

我主要担心的是,如果 IIS 应用程序池使用 WorkflowApplication 进行回收或服务器崩溃,能否恢复工作流.我没有使用 WCF 我打算在 web api 中使用 WorkflowApplication.

My main concern is being able to resume workflows if IIS app pools recycle using WorkflowApplication or the server crashes. I'm not using WCF I plan to use WorkflowApplication inside the web api.

谁能为我指出实现 AppFabric 负责的自定义功能的正确方向?恢复、记录等.

Can anyone point me in the right direction on implementing the custom features that AppFabric was responsible for? Resuming, Logging, etc..

来自 MS:将 IIS 与 AppFabric 结合使用是工作流的首选主机.使用 AppFabric 的工作流的宿主应用程序是 Windows Activation Service,它消除了单独通过 IIS 对 HTTP 的依赖

From MS: Using IIS with AppFabric is the preferred host for workflows. The host application for workflows using AppFabric is Windows Activation Service, which removes the dependency on HTTP over IIS alone

IIS 7.0 出于各种原因定期回收应用程序池.当应用程序池被回收时,IIS 停止接受旧池的消息,并实例化新的应用程序池以接受新请求.如果工作流在发送响应后继续工作,IIS 7.0 将不会知道正在完成的工作,并且可能会回收宿主应用程序池.如果发生这种情况,工作流将中止,跟踪服务将记录一条 1004 - WorkflowInstanceAborted 消息,其中的原因字段为空.

IIS 7.0 recycles application pools periodically for various reasons. When an application pool is recycled, IIS stops accepting messages to the old pool, and instantiates a new application pool to accept new requests. 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. If this happens, the workflow will abort, and tracking services will record a 1004 - WorkflowInstanceAborted message with an empty Reason field.

如果使用了持久化,主机必须从最后一个持久化点明确重启被中止的实例.

If persistence is used, the host must explicitly restart aborted instances from the last persistence point.

如果使用 AppFabric,如果使用持久性,工作流管理服务最终将从最后一个成功的持久性点恢复工作流.如果不使用持久性,并且工作流执行请求/响应模式之外的操作,则工作流中止时数据将丢失.

If AppFabric is used, the workflow management service will eventually resume the workflow from the last successful persistence point if persistence is used. If no persistence is used, and the workflow performs operations outside a Request/Response pattern, data will be lost when the workflow aborts.

推荐答案

一种托管策略是让您的 Web API 方法简单地将消息放入队列(如 MSMQ 或 Rabbit MQ),并为实际托管工作流实例.后端服务会不断读取队列并启动您需要的正确工作流程.

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. The back-end service would continuously read the queue(s) and spin up the correct workflow you need.

这样您就不会遇到可能终止工作流的 IIS 应用程序池回收事件.

This way you don't run into IIS application pool recycling events that could terminate a workflow.

如果您需要让 Web API 方法等待工作流完成,您可以让它等待相关消息"到达队列以表示操作已完成.或者您可以将 WF 实例结果存储在数据库表中.

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. Or you could store the WF instance result in a DB table.

我实际上建议不要使用 App Fabric,而只是推出您自己的托管服务以获得更好的灵活性.此外,根据您想要的行为实现一个相对简单.

I actually recommend not using App Fabric and simply rolling your own hosting service for better flexibility. 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:

这篇关于Windows Workflow Foundation 本地托管和 Web Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆