INT-3337: MongoDbMessageStore Refactoring

JIRA: https://jira.spring.io/browse/INT-3337

INT-3337: Addressing PR comments

INT-3337: Add support to store/read Messages

* Add support to store/read `ErrorMessage`. As a trick for `Throwable` is selected (de)serializing converter

INT-3337: Add converters for `Message<?>` impls

INT-3337: Make `MDbMS.MessageWrapper` AuditAware

Add `_id` persistence field

Addressing PR comments

Polishing

- Docs
- Check for null ApplicationContext
- Add afterPropertiesSet() to tests
This commit is contained in:
Artem Bilan
2014-03-24 13:06:54 +02:00
committed by Gary Russell
parent 6d6bef58b2
commit c11e3ba3b5
11 changed files with 311 additions and 144 deletions

View File

@@ -88,8 +88,8 @@
<para>
Spring Integration's MongoDB module provides the <classname>MongoDbMessageStore</classname> which is an implementation of both
the <classname>MessageStore</classname> strategy (mainly used by the <emphasis>QueueChannel</emphasis> and <emphasis>ClaimCheck</emphasis>
patterns) and the <classname>MessageGroupStore</classname> strategy (mainly used by the <emphasis>Aggregator</emphasis> and
the <classname>MessageStore</classname> strategy (mainly used by the <emphasis>ClaimCheck</emphasis>pattern)
and the <classname>MessageGroupStore</classname> strategy (mainly used by the <emphasis>Aggregator</emphasis> and
<emphasis>Resequencer</emphasis> patterns).
</para>
@@ -111,15 +111,18 @@
and an <emphasis>Aggregator</emphasis>. As you can see it is a simple bean configuration, and it expects a
<classname>MongoDbFactory</classname> as a constructor argument.
</para>
<para>
The <classname>MongoDbMessageStore</classname> expands the <interfacename>Message</interfacename> as a Mongo document
with all nested properties using the Spring Data Mongo Mapping mechanism. It is useful when you need to have access to
the <code>payload</code> or <code>headers</code> for auditing or analytics, for example, against stored messages.
</para>
<important>
<para>
The <classname>MongoDbMessageStore</classname> uses a custom <classname>MappingMongoConverter</classname> implementation
to store <interfacename>Message</interfacename>s as MongoDB documents and there are some limitations
for the properties (<code>payload</code> and <code>header</code> values) of the <interfacename>Message</interfacename>.
For example an <classname>ErrorMessage</classname> can't be converted to the MongoDB document, because it has an
<classname>Exception</classname> property, where the cause property is infintely recursed. Also, there is no ability to
configure
custom converters for complex domain <code>payload</code>s or <code>header</code> values.
For example, there is no ability to configure custom converters for complex domain <code>payload</code>s or <code>header</code> values.
Or to provide a custom <classname>MongoTemplate</classname> (or <classname>MappingMongoConverter</classname>).
To achieve these capabilities, an alternative MongoDB <interfacename>MessageStore</interfacename> implementation has been
introduced; see next paragraph.
</para>
@@ -128,8 +131,7 @@
<emphasis>Spring Integration 3.0</emphasis> introduced the <classname>ConfigurableMongoDbMessageStore</classname> -
<interfacename>MessageStore</interfacename> and <interfacename>MessageGroupStore</interfacename> implementation.
This class can receive, as a constructor argument, a <classname>MongoTemplate</classname>, with which you can
configure with a
custom <classname>WriteConcern</classname>, for example. Another constructor requires a
configure with a custom <classname>WriteConcern</classname>, for example. Another constructor requires a
<classname>MappingMongoConverter</classname>, and a <interfacename>MongoDbFactory</interfacename>,
which allows you to provide some custom conversions for <interfacename>Message</interfacename>s and their properties.
Note, by default, the <classname>ConfigurableMongoDbMessageStore</classname> uses standard Java serialization
@@ -137,8 +139,8 @@
properties from <classname>MongoTemplate</classname>, which is built from the provided
<interfacename>MongoDbFactory</interfacename> and <classname>MappingMongoConverter</classname>.
The default name for the collection stored by the <classname>ConfigurableMongoDbMessageStore</classname> is
<code>configurableStoreMessages</code>. It is recommended to use this implementation for robust and flexible solutions.
The <classname>MongoDbMessageStore</classname> remains for backward compatibility and may be removed in future releases.
<code>configurableStoreMessages</code>. It is recommended to use this implementation for robust and flexible solutions
when messages contain complex data types.
</para>
</section>