AMQP extension example how to implemented

Hi Guys,

I try to test the integration of amqp extension with Axon framework. I found the doc here : https://docs.axoniq.io/reference-guide/extensions/spring-amqp but i need to have more explication about how we configure the connection with AMQP and Axon Framework.

We got some example of code of how we can implemented ?

Also i got this error message : Error processing condition on org.axonframework.extensions.amqp.autoconfig.AMQPAutoConfiguration.amqpMessageConverter

Many thanks,

Dominic

Hi @Dominic_Dubreuil,

We don’t provide a direct example, like we currently have for the Spring Cloud and Kafka Extension. What I can link you to is a piece of code which we used during our training material, which is an exert of an AMQP configuration class:

@Configuration
@Profile("rabbit")
public class AmqpConfig {

    @Bean
    public SpringAMQPMessageSource springAMQPMessageSource(Serializer serializer) {
        return new SpringAMQPMessageSource(serializer) {
            @RabbitListener(queues = "events")
            @Override
            public void onMessage(Message message, Channel channel) {
                super.onMessage(message, channel);
            }
        };
    }

    @Bean
    public Exchange eventsExchange() {
        return ExchangeBuilder.topicExchange("events").build();
    }

    @Bean
    public Queue eventsQueue() {
        return QueueBuilder.durable("events").build();
    }

    @Bean
    public Binding eventsBinding() {
        return BindingBuilder.bind(eventsQueue()).to(eventsExchange()).with("#").noargs();
    }

    @Autowired
    public void config(AmqpAdmin admin, EventProcessingConfigurer epConfig, SpringAMQPMessageSource messageSource) {
        admin.declareExchange(eventsExchange());
        admin.declareQueue(eventsQueue());
        admin.declareBinding(eventsBinding());

        epConfig.registerSubscribingEventProcessor("rabbit-events", c -> messageSource);
    }
}

What you see in this AmqpConfig class, is the creation of a message source, the required RabbitMQ exchange, queue and binding beans, and configuring the SpringAMQPMessageSource as the source for a SubscribingEventProcessor. Note that this configuration further assume the use of the axon-amqp-spring-boot-starter dependency, as that will give you the required converter (to convert events to publishable messages on AMQP) and event publisher (used to actually publish events on a queue).

Hoping this will help you out further @Dominic_Dubreuil!

Cheers,
Steven