Axon framework + Postgresql + RabbitMQ + MongoDB

Hello Gentlemen,

I chose Axon framework as the foundation for my private project and I am loving it. Last night I ran into an issue in the process of adding a Message broker into the fold. Let me take a moment to describe my setup:

Setup that work flawlessly but was limited:

* Services are all Spring-boot based
* Command and Query Services are completely segregated
* Command (microservice) -> Postgresql -> Query(microservice) -> MongoDB, this setup works flawlessly using spring Autoconfiguration
* Command -> RabbitMQ(EventBus) | Postgresql (EventStore) -> Query -> MongoDb (Projection store). 

The last setup seem to be configured correctly also using Spring Autoconfiguration as explained by Axon AMQP extension. However, events are not being published into the queue.

axon:
   serializer:
      general: jackson
      messages: jackson
      events: jackson
   amqp:
      exchange: myExchange
@Configuration
public class RabbitmqConfig {

	@Bean
	public TopicExchange eventsExchange() {
		return ExchangeBuilder.topicExchange(EVENT_EXCHANGE).durable(true).build();
	}

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

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

	@Bean
	public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
		var admin = new RabbitAdmin(connectionFactory);
		admin.declareExchange(eventsExchange());
		admin.declareQueue(eventsQueue());
		admin.declareBinding(eventsBinding());
		return admin;
	}
}

Exchange and queue are created correctly, app starts with errors but I test it, events are recorded in postgresql event store as expected but nothing goes through the eventbus and as such the query side does not see any action. There are no exceptions and I have lower Log level to TRACE.

I know I could have used Axon Server but my used case require additional events from outside my axon base services to hit the broker and be consume by a custom eventListener. This domain messages may not be handled by Axon correctly as it was not meant for that use case.

NB

I have also checked and made sure beans AMQPAutoConfiguration are correctly configured at application startup.

Also, other than those beans shown above, I did not manually create any additional beans, I let Spring Boot AutoConfiguration do its thing. Axon server is correctly disabled by excluding the connector. Should I manually create JDBC eventStore and TokenStores? I looked at the conditions on those auto configured beans but couldn’t find anything out of the ordinary.

Axon -> version 5.8
AMQP extension version -> 4.5

Has anyone seen this kind of behavior, if so what am I missing?

This what axon’s documentation of AMQP extension say.

It turns out my queue configuration had a small issue. I change the below line of code from

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

To

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

and boom everything starts working again as expected.

1 Like