WF4 - 并行使用多个 ReceiveAndSendReply 活动时出现异常
我有一个场景,想要使用并行运行的多个 ReceiveAndSendReply 活动,每个活动都将放入无限 while 循环中,以确保所有活动始终运行和侦听。因此,我使用并行活动来打包所有这些 ReceiveAndSendReply,并将每个 ReceiveAndSendReply 放入条件设置为 true 的 While 活动中。当然,我在 Receive 活动和 SendReplyToRecieve 活动之间放置了一些具有业务逻辑的活动。 现在我遇到一个问题,如果在一个分支中处理请求需要很长时间,那么在此期间所有其他分支都将被阻止。对其他 Receive 活动的任何请求都不会被处理,并且两个客户端(包括调用长时间运行服务的客户端和在服务器进程长时间运行服务进程期间调用其他服务的另一个客户端)也将收到异常。 有人有解决办法吗?抱歉,因为我是新用户,可以发布我的工作流程的图片。
I have a scenario and want to use multiple ReceiveAndSendReply activities running in parallel situation, each of them will be put in an infinite while loop to make sure all activities are always running and listening. So I used a parallel activity to pack all those ReceiveAndSendReply, and each ReceiveAndSendReply was put in a While activity with condition set to true. And of cause, I put some activities with business logic between Receive activity and SendReplyToRecieve activity.
Now I have a problem if it takes a long time to process a request in one branch, then during that time all other branches will be blocked. Any request for other Receive activities will not be processed, and both client, which include the one called long time run service and the other one who called other service during server process long time run service process, will also get exceptions.
Did anybody have an idea to fix it? Sorry since I am new user, can put post image of my workflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
工作流运行时是单线程的,因为给定的工作流实例在任何给定时刻仅在单个线程上执行。因此,当您的工作流程忙于工作时,它无法对其他传入消息做出反应。通常这不是问题,因为工作流程通常不是计算密集型的,并且执行异步 IO 非常容易。可能有帮助的一件事是添加具有真正短超时的延迟活动。它们导致工作流程暂停,使其开始处理下一个请求。还要确保在 Receive 和 SendReply 之间放置尽可能少的活动,并在 SendReply 之后添加短暂的延迟。
The workflow runtime is single treaded in that a given workflow instance only executes on a single thread at any given moment. So while your workflow is busy doing work it can't react to other incoming messages. Normally this isn't a problem as workflow's normally aren't compute intensive and doing async IO is real easy. One thing that might help is adding Delay activities with a real short timeout. They cause the workflow to pause letting it start processing the next request. Also make sure you put as few activities as you can between the Receive and the SendReply and add a short delay right after the SendReply.