Reading Events from an AMQP Queue
Spring has extensive support for reading messages from an AMQP Queue. However, this needs to be 'bridged' to Axon, so that these messages can be handled from Axon as if they are regular event messages.
The SpringAMQPMessageSource
allows event processors to read messages from a queue instead of the event store or event bus. It acts as an adapter between Spring AMQP and the SubscribableMessageSource
needed by these processors.
To receive events from a queue and process them inside an Axon application, you need to configure a SpringAMQPMessageSource
:
@Bean
public SpringAMQPMessageSource myQueueMessageSource(AMQPMessageConverter messageConverter) {
return new SpringAMQPMessageSource(messageConverter) {
@RabbitListener(queues = "myQueue")
@Override
public void onMessage(Message message, Channel channel) throws Exception {
super.onMessage(message, channel);
}
};
}
and then configure a processor to use this bean as the source for its messages:
axon.eventhandling.processors.name.source=myQueueMessageSource
Note that tracking processors are not compatible with the SpringAMQPMessageSource
.