Skip to content

MongoDbChannelMessageStore ignores Auto Index Creation property #8692

Closed
@sdobberstein

Description

@sdobberstein

In what version(s) of Spring Integration are you seeing this issue?

6.1.1

Describe the bug

When starting up the Application the MongoDbChannelMessageStore ignores the spring.data.mongodb.auto-index-creation property and goes ahead and automatically creates the indexes. Looking at the code for MongoDbChannelMessageStore and AbstractConfigurableMongoDbMessageStore it looks like they both create the indexes in the afterPropertiesSet() method without any regard to that property.

The reason it is an issue for us is that we are trying to use it with AWS DocumentDB. In that case the auto-generated name for some of the indexes ends up being too long resulting in the following error:

{
    "ok": 0,
    "code": 67,
    "errmsg": "namespace name generated from index name is too long",
    "operationTime": {
        "$timestamp": {
            "t": 1690812708,
            "i": 1
        }
    }
}

To Reproduce

  1. When setting up your Spring Integration configuration, create a channel that is backed by a MongoDbChannelMessageStore.
@Bean
public MongoDbChannelMessageStore mongoDbChannelMessageStore(MongoDatabaseFactory databaseFactory)
{
	return new MongoDbChannelMessageStore(databaseFactory);
}

@Bean
public MessageChannel myExampleChannel(MongoDbChannelMessageStore mongoDbChannelMessageStore)
{
	MessageGroupQueue messageGroupQueue = new MessageGroupQueue(mongoDbChannelMessageStore, "myExample");
	return new QueueChannel(messageGroupQueue);
}
  1. Turn off auto-index creation.
spring.data.mongodb.auto-index-creation=false
  1. Start up your Application, then check the indexes on the collection.
db.channelMessages.getIndexes();
  1. You will see that the indexes have been created.

Expected behavior

If we turn off the spring.data.mongodb.auto-index-creation property, it should be applied consistently across the project.

Sample

Example repository:
https://github.com/sdobberstein/spring-integration-mongodb-issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions