1
votes

Can a Rebus saga be split into multiple handler classes?

I have a Rebus saga workflow that is initiated by many message types, and is completed by only two message types.

Instead of having a single class implementing all the various IAmInitiatedBy<T> and IHandleMessage<T> I would like to split these out into one class per message that initiates the workflow. And one class that handles the messages that complete the workflow.

So if any new requirements come that could also start the workflow, I simply create a new handler rather than updating an existing.

Is this a valid use case of Rebus Sagas? To split out handlers across multiple classes all working on the same SagaData type.

Initial tests of this seems to be working, but our existing unit tests of the workflow is using the SagaFixture, which I cannot get to work together across multiple fixtures.

1

1 Answers

1
votes

It should work just fine 🙂 but as you have correctly discovered, SagaFixture is not really geared towards serving up multiple saga handler types.

If it's something you would be interested in helping with, I suggest you go fork the Rebus.TestHelpers repository. I'll be happy to help you submit a PR.