Read the events from external service directly into Saga

In my usecase, my start saga generates a list of events to be consumed by external microservice (worker). Once an event is done the worker generates an event.

My listener is able to listen to those events, Is there a way saga can listen to those events directly instead of having a listener in between.

So that once the saga gets the necessary event it can then end that saga based on the business logic.

Saga

  • Run Report 1

  • Run Report 2

  • Run Report 3

So once the saga receives all 3 reports completed event then the saga will end.

Hi Ajinkya Virkar,

I think you are missing all point that saga is getting events asynchronously.
I didn’t try Axon with Message Broker yet but should be a way to subscribe and route your messages to your local EvenBus instance which will route events to your Saga instance accordingly.

The simple way is inject CommandGateway and EventBus in your listener and send commands & events there accordingly.
Keep in mind it will work only with one message client/jvm instance, otherwise you have to route commands/events to right aggregate,saga instances…
Probably there is more elegant way to do it. Also I think you need to look at Distributed implementation and some example which working with Message Broker.

Thanks,
Evgeny Kochnev