Configuration of the MongoDB Dead-Letter Queue with Spring
See Dead-Letter Queue for the general information about the Dead-Letter Queue.
@Configuration
public class AxonConfig {
// omitting other configuration methods...
@Bean
public ConfigurerModule deadLetterQueueConfigurerModule(
MongoTemplate mongoTemplate
) {
// Replace "my-processing-group" for the processing group you want to configure the DLQ on.
return configurer -> configurer.eventProcessing().registerDeadLetterQueue(
"my-processing-group",
config -> MongoSequencedDeadLetterQueue.builder()
.processingGroup("my-processing-group")
.maxSequences(256)
.maxSequenceSize(256)
.mongoTemplate(mongoTemplate)
.transactionManager(config.getComponent(TransactionManager.class))
.serializer(config.serializer())
.build()
);
}
}