【问题标题】:Automatonymous StateMachine how to handle NotAcceptedStateMachineException自动状态机如何处理 NotAcceptedStateMachineException
【发布时间】:2021-12-01 07:54:36
【问题描述】:

有没有办法以通用方式处理 NotAcceptedStateMachineException,例如以请求-响应的方式向客户端返回一些用户友好的消息?

    Automatonymous.NotAcceptedStateMachineException: ExampleSagaState(8dc388ea-99b3-4d21-a3e5-915c4185ec12) Saga exception on receipt of IExampleRequest: Not accepted in state ExampleState
 ---> Automatonymous.UnhandledEventException: The ExampleEvent event is not handled during the ExampleState state for the ExampleStateMachineSaga state machine
   at Automatonymous.AutomatonymousStateMachine`1.DefaultUnhandledEventCallback(UnhandledEventContext`1 context)
   at Automatonymous.AutomatonymousStateMachine`1.UnhandledEvent(EventContext`1 context, State state)
   at Automatonymous.States.StateMachineState`1.Automatonymous.State<TInstance>.Raise[T](EventContext`2 context)
   at Automatonymous.AutomatonymousStateMachine`1.Automatonymous.StateMachine<TInstance>.RaiseEvent[T](EventContext`2 context)
   at Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.Send(SagaConsumeContext`2 context, IPipe`1 next)
   --- End of inner exception stack trace ---
   at Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.Send(SagaConsumeContext`2 context, IPipe`1 next)
   at Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.Send(SagaConsumeContext`2 context, IPipe`1 next)
   at MassTransit.Saga.SendSagaPipe`2.Send(SagaRepositoryContext`2 context)
   at MassTransit.Saga.SendSagaPipe`2.Send(SagaRepositoryContext`2 context)
   at MassTransit.RedisIntegration.Contexts.RedisSagaRepositoryContextFactory`1.Send[T](ConsumeContext`1 context, IPipe`1 next)
   at .MassTransit.RedisIntegration.Contexts.RedisSagaRepositoryContextFactory`1.Send[T](ConsumeContext`1 context, IPipe`1 next)
   at MassTransit.Saga.Pipeline.Filters.CorrelatedSagaFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)

我正在使用请求/响应来执行状态机:

  IRequestClient<IExampleRequest> client = this._busControl.CreateRequestClient<IExampleMessage>(address, (MassTransit.RequestTimeout)Timeout);
  Response<IExampleResponse> response = await client.GetResponse<TRes>(message, new CancellationToken(), new MassTransit.RequestTimeout()).ConfigureAwait(false);

我想得到该 TRes 类型的响应,但显示的是超时。 我试图通过使用 OnUnhandledEvent 来处理这个问题,但在这里我丢失了有关响应类型的信息,所以我无法将其发回。 任何想法如何解决这个问题?谢谢

【问题讨论】:

    标签: masstransit automatonymous


    【解决方案1】:

    没有看到状态机代码,纯属猜测,但报错信息一目了然。状态机未处于处理该事件的状态。

    我建议查看一些涵盖状态机的 samples,如果可能的话 watching the entire season of videos 讨论该示例、状态机以及它们在 MassTransit 中的工作方式。

    【讨论】:

      猜你喜欢
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-19
      • 2016-01-16
      • 1970-01-01
      • 2015-11-24
      相关资源
      最近更新 更多