Windows 工作流程:EventHandlersActivity 未完成

发布于 2024-07-16 13:40:07 字数 6690 浏览 4 评论 0 原文

我有一个带有 EventHandlingScopeActivity (UpdateListenerScope) 的自定义工作流活动。

EventHandlingScopeActivity 内部有一个主 SequenceActivity (UpdateListenerSequenceActivity) 和一个 EventHandlersActivity (UpdateHandlers)。

当主 SequenceActivity 完成时,有时 EventHandlersActivity 将不会完成并允许 EventHandlingScopeActivity 完成,以便工作流继续进行下一个活动。

奇怪的是,UpdateHandlers 有时会完成,有时则不会。 我无法预测或控制 UpdateHandlers 何时保持挂起状态。

以下是典型的工作流跟踪日志(一切正常完成,关键步骤以粗体显示):

System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 :运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Executing, Succeeded)) System.Workflow.Runtime 信息:0:活动状态更改 - 活动:serviceQueueActivity1.UpdateListenerSequenceActivity 旧:正在执行; 新:已关闭 System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity',已关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity ',执行,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity ',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers) ',正在执行,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers',执行,成功)) System.Workflow.Runtime 信息:0:活动状态更改 - 活动:serviceQueueActivity1.UpdateHandlers 旧:正在执行; 新:已关闭 System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers',已关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers) ',执行,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerScope',正在执行,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers) ',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:78f436b4-9f97-4d2b-a3dc-add8acf15c79:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerScope',执行,成功)) System.Workflow.Runtime 信息:0:活动状态更改 - 活动:serviceQueueActivity1.UpdateListenerScope 旧:正在执行; 新增:已关闭

这是工作流跟踪日志 UpdateHandlers 未完成:

System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1 .UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', 执行中, 成功)) System.Workflow.Runtime 信息:0:活动状态更改 - 活动:serviceQueueActivity1.UpdateListenerSequenceActivity 旧:正在执行; 新:已关闭 System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity',已关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity ',执行,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:调度条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope,ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity ',关闭,成功)) System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) 这里缺少一步!!! System.Workflow.Runtime 信息:1:工作流运行时:调度程序:InstanceId:6602768f-f043-4382-9d29-0be944f0d390:完成运行计划条目:SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers,System.EventArgs) System.Workflow.Runtime 信息:0:工作流运行时:WorkflowExecutor:工作流实例“6602768f-f043-4382-9d29-0be944f0d390”没有工作。

有什么想法为什么 EventHandlersActivity 无法完成吗? 此时,工作流将永远挂起,因为事件处理程序正在侦听不会发送的事件。

I have a custom workflow activity with an EventHandlingScopeActivity (UpdateListenerScope).

Inside the EventHandlingScopeActivity is a main SequenceActivity (UpdateListenerSequenceActivity) and an EventHandlersActivity (UpdateHandlers).

When the main SequenceActivity completes, sometimes the EventHandlersActivity will not complete and allow the EventHandlingScopeActivity to complete so that the workflow continues on to the next activity.

The odd thing is that sometimes UpdateHandlers completes and other times it does not. I cannot predict or control when UpdateHandlers will stay hung.

Here is the typical workflow tracing log (everything completes normally, critical step in bold):

System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Executing, Succeeded))
System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: serviceQueueActivity1.UpdateListenerSequenceActivity Old:Executing; New:Closed
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Executing, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Executing, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Executing, Succeeded))
System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: serviceQueueActivity1.UpdateHandlers Old:Executing; New:Closed
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Executing, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerScope', Executing, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateHandlers', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 78f436b4-9f97-4d2b-a3dc-add8acf15c79 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerScope', Executing, Succeeded))
System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: serviceQueueActivity1.UpdateListenerScope Old:Executing; New:Closed

Here is the workflow tracing log UpdateHandlers does not complete:

System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Executing, Succeeded))
System.Workflow.Runtime Information: 0 : Activity Status Change - Activity: serviceQueueActivity1.UpdateListenerSequenceActivity Old:Executing; New:Closed
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerSequenceActivity, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Executing, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Scheduling entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateListenerScope, ActivityStatusChange('(1)serviceQueueActivity1.UpdateListenerSequenceActivity', Closed, Succeeded))
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
Missing step here!!!
System.Workflow.Runtime Information: 1 : Workflow Runtime: Scheduler: InstanceId: 6602768f-f043-4382-9d29-0be944f0d390 : Done with running scheduled entry: SubscriptionEvent((1)serviceQueueActivity1.UpdateHandlers, System.EventArgs)
System.Workflow.Runtime Information: 0 : Workflow Runtime: WorkflowExecutor: workflow instance '6602768f-f043-4382-9d29-0be944f0d390' has no work.

Any ideas why the EventHandlersActivity would not complete? At this point the workflow is forever hung because the event handler is listening for an event that will not be sent.

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

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

发布评论

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

评论(1

攀登最高峰 2024-07-23 13:40:07

根本原因是多个 HandleExternalEventActivity 活动并行侦听同一事件。 基于 http://msmvps.com/blogs/theproblemsolver/archive/2008/09/16/versioning-long-running-workfows-part-3.aspx 使用queue.Peek而不是队列。出队。

Root cause ended up being multiple HandleExternalEventActivity activities listening in parallel for the same event. Created a custom IEventActivity based on the sample at http://msmvps.com/blogs/theproblemsolver/archive/2008/09/16/versioning-long-running-workfows-part-3.aspx using queue.Peek instead of queue.Dequeue.

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