Search code examples
rabbitmqamqpaxon

Issues reading events from RabbitMQ queue on Axon 3.3.5


Using Axon 3.3.5, I am trying to read events from an AMQP queue.

/**
 * AMQP subscribing
 */

@Bean
SpringAMQPMessageSource notificationsEventsQueue(Serializer serializer) {
    return new SpringAMQPMessageSource(serializer) {

        @Override
        @Transactional
        @RabbitListener(id = "eventsQueue", queues = "notificationsEventsQueue")
        public void onMessage(Message message, Channel channel) {
            super.onMessage(message, channel);
        }

    };
}

@Autowired
public void configure(EventProcessingConfiguration conf, SpringAMQPMessageSource src) {
    conf.registerSubscribingEventProcessor("notificationsServiceEventProcessor", c -> src);
}

I debugged the onMessage method and when a new message comes in, the eventProcessors list is always empty, so the message isn't processed by my application.

What am I missing out?


Solution

  • Event Handlers receive their events from the Event Bus by default. If you want handlers to receive events from another source (such as RabbitMQ), you need to explicitly assign that source to a processor, and assign that handler to that processor as well. The easiest way is to put @ProcessingGroup('notificationsServiceEventProcessor') on the eventhandler class.