I'm working on a Axon 3 based application and wondering what would be the preferred way to handle events from external systems or services.
Imagine a situation like this: I ask another services to do something for me and the answer to this something can be interpreted as an event and handled by a saga.
Now I can think of 2 options to handle this event:
- Transform the response into a command and apply an event, but in this case you would have a command like
MarkSomethingHappendCommand
and aSomethingHappendEvent
. And you need an aggregate to handle this. - Use an EventStore instance in the response handler, transform the response to an SomethingHappendEvent and do a
eventStore.publish(event)
to active the saga to continue processing.
Would it be valid, from a Axon Framework perspective, to use the eventbus directly to publish events like this? Would this way also prevent timing issues, like the response from the other service is quicker than committing the UOW from which the call originated?
Thank you in advance!