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

Allow for multiple sagas to be InitiatedBy<> and ConsumerOf<> the same message #40

Open
Place1 opened this issue Jan 18, 2019 · 3 comments

Comments

@Place1
Copy link

Place1 commented Jan 18, 2019

In my usecase i'd like two different sagas (that don't know about eachother) to be able to consume the same message type. Currently this doesn't seem possible as NSaga's design seems to assume that Sagas will never be initiatedby or consume the same message types. For example; in the mediator it's expecting 1 saga for a given initiating message.

Currently I have to work around this issue by copy/pasting my message types so that each saga has it's own messages, even though they do the same thing.

For context, i have raw messages from a queue automatically being converted into saga messages.

@trailmax
Copy link
Member

@Place1 So if we get a message that starts multiple sagas, which one of the sagas should start? All of them? If there is a message that can be consumed by multiple sagas, which one should consume the message? What about order?

@trailmax
Copy link
Member

@Place1 Also what should happen with CorrelationId of saga when multiple sagas are started by the same message?

@Place1
Copy link
Author

Place1 commented Jan 21, 2019

Good questions that i'm not 100% sure how to answer yet, but here are my thoughts:

if we get a message that starts multiple sagas, which one of the sagas should start?

I think if the message can initiate<> many sagas, they should all start.

If there is a message that can be consumed by multiple sagas, which one should consume the message?

again, i think they should all run.

What about order?

order is tricky. i think NSaga should not guarantee any execution order. Perhaps NSaga can implement an interface that allows the ordering behavior to be controlled. Library users could then implement this behavior if they need specific ordering.

what should happen with CorrelationId of saga when multiple sagas are started by the same message?

I think this is a tricky question. Perhaps correlation Ids should be prefixed with something that identifies the saga. The mediator should then handle this when passing messages to sagas. The saga identifier could also be useful to map an OperationResult to the particular Saga that returned it.

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