SagaEventHandler vs EventSourcingHandler

Hi All,
Consider below code snippets one in aggregate and other one is in the saga.

    protected void on(OrderCreatedEvent orderCreatedEvent){
        this.orderId = orderCreatedEvent.orderId;
  @SagaEventHandler(associationProperty = "orderId")
    public void handle(OrderCreatedEvent orderCreatedEvent){
              System.out.println("Saga invoked");
        //associate Saga
        SagaLifecycle.associateWith("paymentId", paymentId);
       System.out.println("order id" + orderCreatedEvent.orderId);
        //send the commands
        commandGateway.send(new CreateInvoiceCommand(paymentId, orderCreatedEvent.orderId));


So is it mandatory to have both @EventHandler and @SagaEventHandler methods always ?So what is happening here is that SagaEventHandler will monitor the EventHandler execution and onsuccess or failure saga state will be updated?Is it?Does SagaEventHander gets executed after EventHandler is finished succesfully or failed ?

When there are mulitple @EventHandler for same events what is the execution order?

Also when you say commandGateway.send(new CreateInvoiceCommand(paymentId, orderCreatedEvent.orderId)); you presume command running in the same service.

How to invoke commands running in a different remote service which is the most practical scenario?

Does Axon support distributed sagas?With AxonServer or Kafka etc

Please calrify.

Hi Isuru!

About the ordering, I don’t think Axon provides an ordering guarantee in this scenario, and, in abstract, you shouldn’t depend on this either as it would make the temporal coupling a nightmare. Can you imagine having to 1) find the handlers, and 2) find out their ordering; to be able to do a code change?. If one of these two operations have a dependency, you’ll need to create a new event and then the saga has to listen to the new event. Or a new command that the saga sends when it receives the event.

I’ll leave the other question for someone else as I have strong views on integration between services.

Hi Augusto,
My question simply boils down to whether axon is supporting distributed sagas where services are running independently and can axon managed a distributed transaction with distributed sagas?Does axon support this at the moment?IF so how?

This is a pervasive use case since most of the services are distributed and might need to participate in a distributed transaction to complete.

It seems distributed command bus is the way to go.I’ll check on that

  • Axon Distributed Command bus

  • Jgroup coommand bus

  • Spring Cloud Connector command bus

What is the most reliable command bus to use?

But still does it support distributed sagas.Please clarify