DLQ MongoTemplate could not be found

I used axon server in my application, i tried to configure the DLQ with mongodb, but this error

Parameter 0 of method deadLetterQueueConfigurerModule in AxonDLQConfig required a bean of type ‘org.axonframework.extensions.mongo.MongoTemplate’ that could not be found

I have this dependencies :


I configure the DLQ like below

public ConfigurerModule deadLetterQueueConfigurerModule(org.axonframework.extensions.mongo.MongoTemplate mongoTemplate) {
    log.debug("##### Register DLQ for processingGroup {} #####", PROCESSING_GROUP);
    return configurer -> configurer.eventProcessing().registerDeadLetterQueue(
            config -> MongoSequencedDeadLetterQueue.builder()
    ).registerDeadLetterPolicy(PROCESSING_GROUP, configuration -> (letter, cause) -> {
        Integer retries = (Integer) letter.diagnostics().getOrDefault("retries", 0);
        if (retries < MAX_RETRIES) {
            return Decisions.requeue(cause, l -> l.diagnostics().and("retries", retries + 1));
        return Decisions.doNotEnqueue();

You can do two things. Either define the Mongotemplate yourself, or change the axon-mongo dependency to axon-mongo-spring-boot-starter to have it setup for you.
Do you also use the Mongo token store or the Mongo saga store?
This is what the auto configuration will use:

    public MongoTemplate axonMongoTemplate(MongoDatabaseFactory factory) {
        String databaseName = axonMongoProperties.getDatabaseName();
        if (isNull(databaseName)) {
            return SpringMongoTemplate.builder()
        } else {
            return SpringMongoTemplate.builder()

When i change the axon-mongo dependency to axon-mongo-spring-boot-starter, i get this error:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventhandling.tokenstore.TokenStore]: Factory method ‘tokenStore’ threw exception; nested exception is com.mongodb.MongoCommandException: Command failed with error 263 (OperationNotSupportedInTransaction): ‘Cannot run ‘createIndexes’ in a multi-document transaction.’ on server localhost:27017. The full response is {“operationTime”: {“$timestamp”: {“t”: 1677869229, “i”: 18}}, “ok”: 0.0, “errmsg”: “Cannot run ‘createIndexes’ in a multi-document transaction.”, “code”: 263, “codeName”: “OperationNotSupportedInTransaction”, “$clusterTime”: {“clusterTime”: {“$timestamp”: {“t”: 1677869229, “i”: 18}}, “signature”: {“hash”: {“$binary”: {“base64”: “AAAAAAAAAAAAAAAAAAAAAAAAAAA=”, “subType”: “00”}}, “keyId”: 0}}}

That depends on how you run mongo, since transactions are only supported for clusters. The easiest way around this for local is to use docker with something like this:

    image: bitnami/mongodb:6.0.4
      - "27017:27017"