恢复自定义构建阻止活动时出现问题

发布于 2025-01-14 00:57:40 字数 2946 浏览 0 评论 0原文

我正在尝试创建一个阻塞活动。恢复工作流时,我调用workflowLaunchpad.ExecutePendingWorkflowAsyc(),此调用会引发 System.ObjectDisposeException 异常。

异常的调用堆栈:

This exception was originally thrown at this call stack:
    Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
    Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(System.Type)
    MediatR.ServiceFactoryExtensions.GetInstances<T>(MediatR.ServiceFactory)
    MediatR.Internal.NotificationHandlerWrapperImpl<TNotification>.Handle(MediatR.INotification, System.Threading.CancellationToken, MediatR.ServiceFactory, System.Func<System.Collections.Generic.IEnumerable<System.Func<MediatR.INotification, System.Threading.CancellationToken, System.Threading.Tasks.Task>>, MediatR.INotification, System.Threading.CancellationToken, System.Threading.Tasks.Task>)
    MediatR.Mediator.PublishNotification(MediatR.INotification, System.Threading.CancellationToken)
    MediatR.Mediator.Publish<TNotification>(TNotification, System.Threading.CancellationToken)
    Elsa.Services.Workflows.WorkflowRegistry.FindInternalAsync(System.Func<Elsa.Providers.Workflows.IWorkflowProvider, System.Threading.Tasks.ValueTask<Elsa.Services.Models.IWorkflowBlueprint>>, System.Threading.CancellationToken)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    ...
    [Call Stack Truncated] 

我试图从 API 端点调用它。代码非常简单,因为我只是为我的下一个项目之一评估 ELSA。


    [Route("api/test")]
    [ApiController]
    public class TestController : ControllerBase
    {

        private ISharePointTaskInvoker invoker;
        private IWorkflowLaunchpad workflowLaunchpad;
        public TestController(ISharePointTaskInvoker invoker, IWorkflowLaunchpad workflowLaunchpad)
        {
            this.workflowLaunchpad = workflowLaunchpad;
            this.invoker = invoker; 
        }

        [HttpPost]
        public async void Post(RequestData data)
        {           
            var q = new WorkflowsQuery(nameof(SharePointTask), new SharePointTaskBookmark(), data.CorrelationId, data.WorkflowInstanceId);

            IEnumerable<CollectedWorkflow> wfs = await workflowLaunchpad.FindWorkflowsAsync(q);
            
            foreach(CollectedWorkflow wf in wfs)
            {
                 await workflowLaunchpad.ExecutePendingWorkflowAsync(wf);
            }

        }
    }


    public class RequestData
    {
        public string WorkflowInstanceId { get; set; }
        public string ActivityId { get; set; }
        public string CorrelationId { get; set; }

    }

你知道我错过了什么,导致了这个 ObjectDisposeException 吗?

I am trying to create a blocking activity. When resuming the workflow, I call workflowLaunchpad.ExecutePendingWorkflowAsyc() and this call throws a System.ObjectDisposedException exception.

the callstack of the exception:

This exception was originally thrown at this call stack:
    Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
    Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(System.Type)
    MediatR.ServiceFactoryExtensions.GetInstances<T>(MediatR.ServiceFactory)
    MediatR.Internal.NotificationHandlerWrapperImpl<TNotification>.Handle(MediatR.INotification, System.Threading.CancellationToken, MediatR.ServiceFactory, System.Func<System.Collections.Generic.IEnumerable<System.Func<MediatR.INotification, System.Threading.CancellationToken, System.Threading.Tasks.Task>>, MediatR.INotification, System.Threading.CancellationToken, System.Threading.Tasks.Task>)
    MediatR.Mediator.PublishNotification(MediatR.INotification, System.Threading.CancellationToken)
    MediatR.Mediator.Publish<TNotification>(TNotification, System.Threading.CancellationToken)
    Elsa.Services.Workflows.WorkflowRegistry.FindInternalAsync(System.Func<Elsa.Providers.Workflows.IWorkflowProvider, System.Threading.Tasks.ValueTask<Elsa.Services.Models.IWorkflowBlueprint>>, System.Threading.CancellationToken)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    ...
    [Call Stack Truncated] 

I am trying to call this from a API endpoint. The code is very simple, as I am only evaluating ELSA for one of my next project.


    [Route("api/test")]
    [ApiController]
    public class TestController : ControllerBase
    {

        private ISharePointTaskInvoker invoker;
        private IWorkflowLaunchpad workflowLaunchpad;
        public TestController(ISharePointTaskInvoker invoker, IWorkflowLaunchpad workflowLaunchpad)
        {
            this.workflowLaunchpad = workflowLaunchpad;
            this.invoker = invoker; 
        }

        [HttpPost]
        public async void Post(RequestData data)
        {           
            var q = new WorkflowsQuery(nameof(SharePointTask), new SharePointTaskBookmark(), data.CorrelationId, data.WorkflowInstanceId);

            IEnumerable<CollectedWorkflow> wfs = await workflowLaunchpad.FindWorkflowsAsync(q);
            
            foreach(CollectedWorkflow wf in wfs)
            {
                 await workflowLaunchpad.ExecutePendingWorkflowAsync(wf);
            }

        }
    }


    public class RequestData
    {
        public string WorkflowInstanceId { get; set; }
        public string ActivityId { get; set; }
        public string CorrelationId { get; set; }

    }

Do you have an idea, what I am missing, that's causing this ObjectDisposedException?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文