Event published by EventScheduler is not received by the same SagaEventHandler

I am testing event scheduler on axon version 4. The event is published according to my setting, However only the normal event handler is receiving this event. My SagaEventHandler is not receiving it. What could be the problem?

Saga code:

private String orderId;
private String paymentId;

@Autowired
private transient EventScheduler eventScheduler;

@StartSaga
@SagaEventHandler(associationProperty = “orderId”)
public void on(OrderCreatedEvent event) {
orderId = event.getOrderId();
eventScheduler.schedule(Duration.ofSeconds(30), new OrderChargedEvent(paymentId, orderId));
}

@EndSaga
@SagaEventHandler(associationProperty = “orderId”)
public void on(OrderChargedEvent event) {
logger.info(“received”);
}

Normal LoggingEventHandler is receiving this event.

@EventHandler
public void on(Object event) {
logger.info("Event received: " + event.toString() + "Thread id: " + Thread.currentThread().getId());
}

I think the reason is I am using Kafka and specify the source to be kafkaMessageSource. That is why I am not seeing another processor for the event published internally by Saga. Is there any way the same saga can be in multiple processor groups so that the handler can receive event from multiple sources?

Hi CFU8899 (assuming you have a name, but in absence of that I’ll use your gmail account),

Your assumption why you’re not seeing the event pop up in your saga is correct.
Currently, an Event Processor (also the backbone for your Saga instances in regards to receiving events) can only have a single message source.
We are discussing a solution where you could have multiple message sources for a given Event Processor.
This is however not in place and I am hard pressed to give you timing on this.

However, what you could do instead of using the EventScheduler is leveraging the DeadlineManager to schedule a message for your Saga.
Deadlines will be dealt with by the instances which has set them, without the message being populated on the EventBus.
So, whether this is a solution to your situation depends on the use case of your OrderChargedEvent.

If more parties should be able to listen to it, then I assume it will not resolve the problem at hand.

If the later is the case, you could opt to using Axon Server to send events between your micro services.
Note that a single Axon Server instance is free of charge - as you’re in a testing phase of building your application I would recommend you take it into account (if you haven’t already).

Cheers,
Steven