Domo42/saga-lib

Support for nested executions

Closed this issue · 0 comments

It would be nice to have better support for nested executions.

A nested execution is when you call into the MessageStream twice (or more) in the same call stack.
Such a call stack would look like this:

myproject.anothersaga.handle(AnotherMessage)
com.sagaLib.xxx
com.sagaLib.xxx
com.sagaLib.MessageStream.handle
myproject.mysaga.handle(MyMessage)
com.sagaLib.xxx
com.sagaLib.xxx
com.sagaLib.MessageStream.handle`

This is helpfull to synchronously handle events in the same transaction.

The current MessageStream API could be exectend like this:

handle(Object message, Map<String, Object> headers)
handle(ExecutionContext parentContext, Object message, Map<String, Object> headers)

This combined with my second feature request "Custom Instance Matcher Strategies" would be very powerfull.
It would probably be a good idea to give the possibility to specify the "Custom Instance Matcher Strategy" seperatly for nested executions. This means that you can specify the Strategy based on the message type beeing handled and on the current execution context (which can be a nested context or not).