[英]MassTransit handling Faults in Saga
I'm trying to handle specific Fault
inside Saga instance like described in https://masstransit-project.com/MassTransit/usage/exceptions.html#faults .我正在尝试处理 Saga 实例中的特定
Fault
如https://masstransit-project.com/MassTransit/usage/exceptions.html#faults 中所述。 In my StateMachine
class I have:在我的
StateMachine
课程中,我有:
Event(
() => OnError,
x => x
.CorrelateById(context => context.Message.Message.CorrelationId))
DuringAny(WhenError());
...
public Event<CustomCommand> CustomCommandReceived { get; protected set; }
public Event<Fault<CustomCommand>> OnError { get; protected set; }
...
private EventActivityBinder<RequestSaga, Fault<CustomCommand>> WhenError()
{
return When(OnError)
.Then(context =>
{
context.Instance.Status = RequestProcessingStatus.Error;
});
}
But when Fault<CustomCommand>
occured, code inside handler did'not execute and Fault<CustomCommand>
message goes to ..._skipped
queue.但是当
Fault<CustomCommand>
发生时,处理程序中的代码没有执行并且Fault<CustomCommand>
消息进入..._skipped
队列。
What am I doing wrong??我究竟做错了什么??
Is CustomCommands
handled in the Initial state, and throwing the exception? CustomCommands
是否在初始状态下处理并抛出异常? That would prevent the saga instance from being saved, and thus after the fault is published, would cause the fault to be ignored since DuringAny
does not include the Initial or Final states.这将阻止保存 saga 实例,因此在发布错误后,将导致错误被忽略,因为
DuringAny
不包括初始或最终状态。 If you want to handle the fault in the Initial state, you need to add it explicitly.如果要处理Initial状态下的故障,需要显式添加。
Initially(WhenError());
DuringAny(WhenError());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.