Hello I try to configure my MongoDB Axon setup with RabbitMQ / later then with Azure Service Bus… I was trying based on the sample application ‘amqp-axon-example’ GitHub - AxonFramework/extension-amqp: Axon Framework extension for AMQP integration to publish and handle Event messages.
but every time when I configure my MongoDB with the following configuration I do not see any events in RabbitMQ…
@Component
class AxonMongoDBConfiguration {
/**
* 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.
*
* @param messageConverter Converter to/from AMQP Messages to/from Axon Messages.
*/
@Bean
fun amqpMessageSource(messageConverter: AMQPMessageConverter): SpringAMQPMessageSource {
return object : SpringAMQPMessageSource(messageConverter) {
@RabbitListener(queues = [AMQPAxonExampleApplication.QUEUE_NAME])
override fun onMessage(message: Message?, channel: Channel?) {
println("amqp event $message received")
super.onMessage(message, channel)
}
}
}
companion object {
const val DATABASE_NAME = "eventstore"
}
/**
*
* Create a Mongo based Event Storage Engine.
*/
@Bean
fun storageEngine(client: MongoClient?): EventStorageEngine? {
return MongoEventStorageEngine.builder()
.eventSerializer(
XStreamSerializer.builder()
.xStream(SecureXStreamSerializer.xStream())
.build()
)
.snapshotSerializer(
XStreamSerializer.builder()
.xStream(SecureXStreamSerializer.xStream())
.build()
)
.mongoTemplate(
DefaultMongoTemplate
.builder()
.mongoDatabase(client, DATABASE_NAME)
.build()
).build()
}
/**
* Uses the Configurer to wire everything together including Mongo as the Event and Token Store.
*/
@Autowired
fun configuration(configurer: Configurer, client: MongoClient) {
configurer
.configureEmbeddedEventStore {
storageEngine(client)
}
.eventProcessing { conf -> conf.registerTokenStore { tokenStore(client, it.serializer()) } }
}
/**
* Create a Mongo based
* Token Store.
*/
fun tokenStore(client: MongoClient, serializer: Serializer): TokenStore = MongoTokenStore.builder()
.mongoTemplate(
DefaultMongoTemplate.builder()
.mongoDatabase(client, DATABASE_NAME)
.build()
)
.serializer(serializer)
.build()
}
when I replace it with the following from the sample app… I see the events…
what I am missing here ?
/**
* Creates an InMemoryEventStorageEngine.
* NOT PRODUCTION READY
*/
@Bean
fun storageEngine(): EventStorageEngine = InMemoryEventStorageEngine()
/**
* Creates an InMemoryTokenStore.
* NOT PRODUCTION READY
*/
@Bean
fun tokenStore(): TokenStore = InMemoryTokenStore()
Sample to reproduce is here:
maybe somebody can help me