GH-8692 Add createIndexes to MongoDbMessageStore

Fixes https://github.com/spring-projects/spring-integration/issues/8692

* Added `createIndexes` in `AbstractConfigurableMongoDbMessageStore`
* Added Javadoc for `setCreateIndex()` method
* Removed `afterPropertiesSet()` in `MongoDbChannelMessageStore` and update `whats-new.adoc` and `mongodb.adoc` files

**Cherry-pick to `6.1.x` & `6.0.x`**
This commit is contained in:
Adama Sorho
2023-08-28 15:02:58 -04:00
committed by Artem Bilan
parent 3f5f32b1e0
commit 32eba4ecb9
6 changed files with 71 additions and 5 deletions

View File

@@ -197,6 +197,19 @@ It builds a `MongoTemplate` from the provided `MongoDbFactory` and `MappingMongo
The default name for the collection stored by the `ConfigurableMongoDbMessageStore` is `configurableStoreMessages`.
We recommend using this implementation to create robust and flexible solutions when messages contain complex data types.
Starting with version 6.0.8, the `AbstractConfigurableMongoDbMessageStore` provides a `setCreateIndexes(boolean)` (defaults to `true`) option which can be used to disable the auto indexes creation.
The following example shows how to declare a bean and disable the auto indexes creation:
[source, java]
----
@Bean
public MongoDbChannelMessageStore mongoDbChannelMessageStore(MongoDatabaseFactory databaseFactory) {
MongoDbChannelMessageStore mongoDbChannelMessageStore = new MongoDbChannelMessageStore(databaseFactory);
mongoDbChannelMessageStore.setCreateIndexes(false);
return mongoDbChannelMessageStore;
}
----
[[mongodb-priority-channel-message-store]]
=== MongoDB Channel Message Store
@@ -231,6 +244,22 @@ To configure that scenario, you can extend one message store bean from the other
<int:priority-queue message-store="priorityStore"/>
</int:channel>
----
[[abstract-configurable-mongodb-message-store-with-auto-index-creation-disable]]
=== Using AbstractConfigurableMongoDbMessageStore with auto index creation disable
Starting with version 6.0.8, the `AbstractConfigurableMongoDbMessageStore` implements a `setCreateIndex(boolean)` which can be use to desable or enable (default) the auto index creation.
The following example shows how to declare a bean and disable the auto index creation:
[source, java]
----
@Bean
public AbstractConfigurableMongoDbMessageStore mongoDbChannelMessageStore(MongoDatabaseFactory databaseFactory)
{
AbstractConfigurableMongoDbMessageStore mongoDbChannelMessageStore = new MongoDbChannelMessageStore(databaseFactory);
mongoDbChannelMessageStore.setCreateIndex(false);
return mongoDbChannelMessageStore;
}
----
[[mongodb-metadata-store]]
=== MongoDB Metadata Store

View File

@@ -37,7 +37,7 @@ See, for example, `transformWith()`, `splitWith()` in xref:dsl.adoc#java-dsl[ Ja
See xref:configuration/global-properties.adoc[Global Properties] for more information.
- The `@MessagingGateway` and `GatewayEndpointSpec` provided by the Java DSL now expose the `errorOnTimeout` property of the internal `MethodInvocationGateway` extension of the `MessagingGatewaySupport`.
See xref:gateway.adoc#gateway-no-response[Gateway Behavior When No response Arrives] for more information.
See xref:gateway.adoc#gateway-no-response[ Gateway Behavior When No response Arrives] for more information.
[[x6.2-websockets]]
=== WebSockets Changes
@@ -57,3 +57,9 @@ See xref:kafka.adoc#kafka-inbound-pollable[Kafka Inbound Channel Adapter] for mo
The `JdbcMessageStore`, `JdbcChannelMessageStore`, `JdbcMetadataStore`, and `DefaultLockRepository` implement `SmartLifecycle` and perform a`SELECT COUNT` query, on their respective tables, in the `start()` method to ensure that the required table (according to the provided prefix) is present in the target database.
See xref:jdbc/message-store.adoc#jdbc-db-init[Initializing the Database] for more information.
[[x6.2-mongodb]]
=== MongoDB support change
A new option `setCreateIndexes(boolean)` has been introduced in `AbstractConfigurableMongoDbMessageStore` to disable the auto indexes creation.
See xref:mongodb.adoc#mongodb-message-store[MongoDB Message Store] for an example.