Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any option to have Fault<> consumer in MassTransitStateMachine? #54

Closed
oleksiikraievyi opened this issue Jan 29, 2019 · 4 comments

Comments

@oleksiikraievyi
Copy link

I have a saga which subscribes to response events which are produced by external services. In other words, saga publishes message, external event handler subscribed and responds to saga. These external event handlers have also Fault<> consumers. So, the question is, can saga be configured subscribe to these fault consumers ?

@oleksiikraievyi oleksiikraievyi changed the title Is there any option to have Fault<> consumer in MassTransitSaga ? Is there any option to have Fault<> consumer in MassTransitStateMachine? Jan 29, 2019
@phatboyg
Copy link
Member

Yes, Faults can be observed by state machines.

public Event<Fault<CreateCustomer>> CreateCustomerFaulted {get; private set;}

To initialize it:

Event(() => CreateCustomerFaulted, x => x.CorrelateById(m => m.Message.Message.CommandId));

Correlating on the original message property, which is included in the fault message.

@oleksiikraievyi
Copy link
Author

@phatboyg
And how it works with saga subscribed ?
If external event handler fails with exception n times, Fault<> handler will be triggered on this external service and saga ?

@phatboyg
Copy link
Member

If a consumer throws an exception, and exhausts all retries, the Fault is published by MT. Assuming that a saga is observing that Fault event, and it can be correlated to a saga instance, either a new instance or existing instance, it would be delivered to the saga.

@oleksiikraievyi
Copy link
Author

oleksiikraievyi commented Jan 30, 2019

Thanks, you’ve helped me a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants