Java & DSL Config for the QueueChannel

Also fix some typos in the `mongodb.adoc`
This commit is contained in:
Artem Bilan
2015-10-08 17:56:08 -04:00
committed by Gary Russell
parent bbfde40694
commit d21b42dbcf
2 changed files with 36 additions and 4 deletions

View File

@@ -505,6 +505,38 @@ Since _version 4.0_, it is recommended that `QueueChannel` s are configured to u
These are generally optimized for this use, when compared with a general message store.
If the `ChannelMessageStore` is a `ChannelPriorityMessageStore` the messages will be received in FIFO within priority order.
The notion of priority is determined by the message store implementation.
For example the Java Configuration for the <<mongodb-priority-channel-message-store>>:
[source,java]
----
@Bean
public BasicMessageGroupStore mongoDbChannelMessageStore(MongoDbFactory mongoDbFactory) {
MongoDbChannelMessageStore store = new MongoDbChannelMessageStore(mongoDbFactory);
store.setPriorityEnabled(true);
return store;
}
@Bean
public PollableChannel priorityQueue(BasicMessageGroupStore mongoDbChannelMessageStore) {
return new QueueChannel(new MessageGroupQueue(mongoDbChannelMessageStore, "priorityQueue"));
}
----
NOTE: Pay attention to the `MessageGroupQueue` class.
That is a `BlockingQueue` implementation to utilize the `MessageGroupStore` operations.
The same with Java DSL may look like:
[source,java]
----
@Bean
public IntegrationFlow priorityFlow(PriorityCapableChannelMessageStore mongoDbChannelMessageStore) {
return IntegrationFlows.from((Channels c) ->
c.priority("priorityChannel", mongoDbChannelMessageStore, "priorityGroup"))
....
.get();
}
----
Another option to customize the QueueChannel environment is provided by the `ref` attribute of the `<int:queue>` sub-element.
This attribute implies the reference to any `java.util.Queue` implementation.

View File

@@ -107,11 +107,11 @@ The default name for the collection stored by the `ConfigurableMongoDbMessageSto
It is recommended to use this implementation for robust and flexible solutions when messages contain complex data types.
[[mongodb-priority-channel-message-store]]
==== MongodDB Channel Message Store
==== MongoDB Channel Message Store
Starting with _version 4.0_, the new `MongoDbChannelMessageStore` has been introduced; it is an optimized `MessageGroupStore` for use in `QueueChannel` s.
With `priorityEnabled = true`, it can be used in `<int:priority-queue>` s to achieve _priority_ order polling for persisted messages.
The _priority_ MonogDB document field is populated from the `IntegrationMessageHeaderAccessor.PRIORITY` (`priority`) message header.
The _priority_ MongoDB document field is populated from the `IntegrationMessageHeaderAccessor.PRIORITY` (`priority`) message header.
In addition, all MongoDB `MessageStore` s now have a `sequence` field for MessageGroup documents.
The `sequence` value is the result of an `$inc` operation for a simple `sequence` document from the same collection, which is created on demand.
@@ -141,9 +141,9 @@ To configure that scenario, simply extend one message store bean from the other:
----
[[mongodb-metadata-store]]
==== MongodDB Metadata Store
==== MongoDB Metadata Store
As of _Spring Integration 4.2_, a new MongodDB-based `MetadataStore` (<<metadata-store>>) implementation is available.
As of _Spring Integration 4.2_, a new MongoDB-based `MetadataStore` (<<metadata-store>>) implementation is available.
The `MongoDbMetadataStore` can be used to maintain metadata state across application restarts.
This new `MetadataStore` implementation can be used with adapters such as: