My Axon 4 application does not publish events on RabbitMQ

Hello every one,

I decided to exclude the axon-server-connector in order to use axon as in axon 3. events a properly stored in my mongo store but nothing is publish in rabbit queue.
with the actual configuration everything works fine with axon 3.4.2.
1- I was wondering if there is a specific configuration for axon 4 that need to be set in order to publish on rabbit.
Here is my configuration.
2- Is it possible to use the spring-cloud-stream declarative configuration instead of the spring-boot-starter-amq standard configuration?

pom.xml

`

org.springframework.boot

spring-boot-starter-amqp

org.springframework.boot

spring-boot-starter-webflux

org.springframework.cloud

spring-cloud-stream-binder-rabbit

org.springframework.cloud

spring-cloud-stream-reactive

org.springframework.boot

spring-boot-starter-data-mongodb-reactive

org.axonframework

axon-spring-boot-starter

${axonframework-version}

org.axonframework

axon-server-connector

org.axonframework.extensions.mongo

axon-mongo

${axonmongo-version}

`

Amqp configuration

`

@Configuration

public class AMQPConfiguration {

@Value("${axon.amqp.exchange}")

private String exchange;

@Bean

public Exchange exchange() {

return ExchangeBuilder

.topicExchange(exchange)

.build();

}

@Bean

public Queue defaultEventsQueue() {

return QueueBuilder

.durable(DefaultAMQProperties.DFMS_EVENTS.getQueue())

.build();

}

@Bean

public Binding defaultBinding() {

return BindingBuilder

.bind(defaultEventsQueue())

.to(exchange())

.with(DefaultAMQProperties.DFMS_EVENTS.getRoutingKey()
.noargs();

}

@Autowired

public void configure(AmqpAdmin admin) {

admin.declareExchange(exchange());

admin.declareQueue(defaultEventsQueue());

admin.declareBinding(defaultBinding());

}

}

`

Routing key resolver bean

`

@Component

@Slf4j

public class DfmsRoutingKeyResolver implements RoutingKeyResolver {

@Override

public String resolveRoutingKey(EventMessage<?> event) {

log.info(“Resolving Routing Key”);

final AbtractEvent myEvent = (AbtractEvent) event.getPayload();

final String customRoutingKey = myEvent.getRoutingKey();

if (StringUtils.isEmpty(customRoutingKey) || StringUtils.isBlank(customRoutingKey)) {

log.info(“no custom routing key found a default routing key will be used.”);

return event.getPayloadType().getPackage().getName();

} else {

log.info(“Custom routing key found. value: {}”, customRoutingKey);

return customRoutingKey;

}

}

}

`

Event store configuration

`

@Configuration

@AllArgsConstructor

public class EventStorageConfiguration {

private final AxonProperties properties;

@Bean

public EventStorageEngine engineStorage(MongoTemplate template){

return MongoEventStorageEngine.builder().mongoTemplate(template).build();

}

@Bean

EventStore eventStore(EventStorageEngine eventStorageEngine) {

return EmbeddedEventStore.builder().storageEngine(eventStorageEngine).build();

}

@Bean

public MongoTemplate template(MongoClient client) {

return DefaultMongoTemplate.builder().mongoDatabase(client, properties.getDatabase()).build();

}

@Bean

public TokenStore tokenStore(Serializer serializer, MongoTemplate template) {

return MongoTokenStore.builder().serializer(serializer).mongoTemplate(template).build();

}

@Bean

public Snapshotter snapshotter(ParameterResolverFactory parameterResolverFactory, EventStore eventStore, TransactionManager transactionManager) {

final Executor executor = Executors.newSingleThreadExecutor();

return SpringAggregateSnapshotter.builder().parameterResolverFactory(parameterResolverFactory).eventStore(eventStore).executor(executor)

.transactionManager(transactionManager).build();

}

@Bean

public SnapshotTriggerDefinition snapshotTriggerDefinition(Snapshotter snapshotter) throws Exception {

return new EventCountSnapshotTriggerDefinition(snapshotter, properties.getSnapshotLimit());

}

}

`

Cheers
Martin.

Hello,

You need axon amqp starter maven dependency included:

<dependency>
    <groupId>org.axonframework.extensions.amqp</groupId>
    <artifactId>axon-amqp-spring-boot-starter</artifactId>
</dependency>

Best,
Ivan

Thanks Ivan with the dependency include it worked perfectly.

Martin.