[axonframework] Axon 3 saga event handler running twice for a single event

Hi Justin,

I suspect a double registration of the Saga with the Event Bus (or Store). What is the name of the Saga?

Cheers,

Allard

I need to up this question.
I have exactly the same question, my Saga event handler running twice.

I’m using subscribingSagaManager configuration. How to handle this?

My saga name is PollCreationSaga

Hi Vladimir,

Could you send a snippet of your configuration?

Maybe that might shed some light on the situation.

As Allard responded on the previous requester, it’s probably due to a double registration of the Saga; hence why I’m asking for a view on your config.

Cheers,

Steven

@Bean
public SpringAMQPMessageSource topicQueue(Serializer serializer) {
    return new SpringAMQPMessageSource(serializer) {

        @RabbitListener(queues = "topics")
        @Override
        @Transactional
        public void onMessage(Message message, Channel channel) throws Exception {
            String b = new String(message.getBody());
            System.out.println("got event to saga "+b);

            super.onMessage(message, channel);
        }
    };
}

@Bean
public SagaConfiguration<PollCreationSaga> orderSagaConfiguration(Serializer serializer) {
    SagaConfiguration<PollCreationSaga> sagaConfiguration = SagaConfiguration.subscribingSagaManager(PollCreationSaga.class, c-> topicQueue(serializer));

    return sagaConfiguration;
}

Like in the Justin’s post

Hi Vladimir,

The SagaConfiguration bean you create in configuration will get the name ‘orderSagaConfiguration’ because of how the function is named.
This is different from the configuration bean Axon will create, which will be {Saga-Name}Configuration.

That would come down to a bean name of pollCreationSagaConfiguration.

As the names are different, the Axon Configuration will thus not see that you’re already specifying a config for that Saga and thinks it has to create its own.

This should thus be what results in your saga being hit twice.

Test if the duplicate-saga-event-handling is removed if you rename the orderSagaConfiguration() function to pollCreateionSagaConfiguration().

Hope this helps!

Cheers,

Steven

Hi Steven,

wow great, everything is working now!

Thank you for the help