Skip to content

Commit

Permalink
Java & DSL Config for the QueueChannel
Browse files Browse the repository at this point in the history
Also fix some typos in the `mongodb.adoc`
  • Loading branch information
artembilan authored and garyrussell committed Oct 9, 2015
1 parent bbfde40 commit d21b42d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
32 changes: 32 additions & 0 deletions src/reference/asciidoc/channel.adoc
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/reference/asciidoc/mongodb.adoc
Expand Up @@ -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.
Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit d21b42d

Please sign in to comment.