polishing

This commit is contained in:
Mark Fisher
2011-08-31 15:26:47 -04:00
parent 7813e61100
commit be817cf937
2 changed files with 63 additions and 53 deletions

View File

@@ -1,36 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="mongodb"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>MongoDb Support</title>
<para>
Since version 2.1 Spring Integration introduces support for <ulink url="http://www.mongodb.org/">MongoDb</ulink> database - <emphasis>"high-performance, open source, document-oriented database" </emphasis>
This support comes in the form of MongoDb-based MessageStore.
As of version 2.1 Spring Integration introduces support for <ulink url="http://www.mongodb.org/">MongoDB</ulink>:
a <emphasis>"high-performance, open source, document-oriented database"</emphasis>.
This support comes in the form of a MongoDB-based MessageStore.
</para>
<section id="mongodb-intro">
<title>Introduction</title>
<para>
To download, install and run MongoDb please refer to <ulink url="http://www.mongodb.org/downloads">MongoDb documentation</ulink>
To download, install, and run MongoDB please refer to the <ulink url="http://www.mongodb.org/downloads">MongoDB documentation</ulink>.
</para>
</section>
<section id="mongodb-connection">
<title>Connecting to MongoDb</title>
<para>To begin interacting with MongoDb you first need to connect to it. Spring Integration uses support provided by another Spring project -
<ulink url="http://www.springsource.org/spring-data/mongodb">Spring Data MongoDB</ulink> which uses an all familiar Spring's <classname>ConnectionFactory</classname>.
abstraction to simplify integration with MongoDB Client API. </para>
<para>To begin interacting with MongoDB you first need to connect to it. Spring Integration builds on the support provided by another
Spring project, <ulink url="http://www.springsource.org/spring-data/mongodb">Spring Data MongoDB</ulink>, which provides a factory
class called <classname>MongoDbFactory</classname> that simplifies integration with the MongoDB Client API.</para>
<para><emphasis>MongoDbFactory</emphasis> </para>
<para>
To connect to MongoDb you would use one of the implementations of <classname>MongoDbFactory</classname> interface
To connect to MongoDB you can use an implementation of the <classname>MongoDbFactory</classname> interface:
<programlisting lang="java"><![CDATA[public interface MongoDbFactory {
/**
* Creates a default {@link DB} instance.
*
* @return
* @return the DB instance
* @throws DataAccessException
*/
DB getDb() throws DataAccessException;
@@ -39,56 +43,59 @@
* Creates a {@link DB} instance to access the database with the given name.
*
* @param dbName must not be {@literal null} or empty.
* @return
*
* @return the DB instance
* @throws DataAccessException
*/
DB getDb(String dbName) throws DataAccessException;
}]]></programlisting>
</para>
<para>Example below shows how to create <classname>SimpleMongoDbFactory</classname> </para>
<para>The example below shows <classname>SimpleMongoDbFactory</classname>, the out-of-the-box implementation:</para>
<para>In Java:
<programlisting lang="java"><![CDATA[MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new Mongo(), "test");]]></programlisting>
</para>
<para>Or as Spring configuration::
<para>Or in Spring's XML configuration:
<programlisting lang="xml"><![CDATA[<bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg>
<bean class="com.mongodb.Mongo"
</constructor-arg>
<constructor-arg value="test"/>
<constructor-arg>
<bean class="com.mongodb.Mongo"/>
</constructor-arg>
<constructor-arg value="test"/>
</bean>]]></programlisting>
</para>
<para>
As you can see <classname>SimpleMongoDbFactory</classname> takes two arguments; A connection object <classname>Mongo</classname> and String specifying the name of the database.
If you need to specify properties such as <code>host</code>, <code>port</code> etc, you can pass those using one of the constructors provided by <classname>Mongo</classname>.
For more information on how to configure please refer to
<ulink url="http://static.springsource.org/spring-data/data-document/docs/current/reference/html/">Spring-Data-Document</ulink> reference documentation.
<para>
As you can see <classname>SimpleMongoDbFactory</classname> takes two arguments: 1) a <classname>Mongo</classname> instance and
2) a String specifying the name of the database. If you need to configure properties such as <code>host</code>, <code>port</code>, etc,
you can pass those using one of the constructors provided by the underlying <classname>Mongo</classname> class.
For more information on how to configure MongoDB, please refer to the
<ulink url="http://static.springsource.org/spring-data/data-document/docs/current/reference/html/">Spring-Data-Document</ulink> reference.
</para>
</section>
<section id="mongodb-message-store">
<title>MongoDb Message Store</title>
<title>MongoDB Message Store</title>
<para>
As described in EIP, a <ulink url="http://www.eaipatterns.com/MessageStore.html">Message Store</ulink> allows you to persist Messages.
This can be very useful when dealing with components that have a capability to buffer messages
(<emphasis>QueueChannel, Aggregator, Resequencer</emphasis>, etc.) if reliability is a concern.
In Spring Integration, the MessageStore strategy also provides the foundation for the
<ulink url="http://www.eaipatterns.com/StoreInLibrary.html">ClaimCheck</ulink> pattern, which is described in EIP as well.
</para>
<para>
As described in the EIP <ulink url="http://www.eaipatterns.com/MessageStore.html">MessageStore</ulink> allows you to persist Messages which can be very useful when dealing
with components that have capability to buffer messages (<emphasis>QueueChannel, Aggregator, Resequencer</emphasis>) if reliability is a concern as well as patterns such as
<ulink url="http://www.eaipatterns.com/StoreInLibrary.html">ClaimCheck</ulink>
<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
<emphasis>Resequencer</emphasis> patterns).
</para>
<para>
Spring Integration MongoDb module provides <classname>MongoDbMessageStore</classname> which is the implementation of both <classname>MessageStore</classname> strategy
(mainly used by <emphasis>QueueChannel</emphasis> and <emphasis>ClaimCheck</emphasis> patterns) as well as <classname>MessageGroupStore</classname> strategy
(mainly used by <emphasis>Aggregator</emphasis> and <emphasis>Resequencer</emphasis> patterns)
</para>
<para>
<programlisting lang="xml"><![CDATA[<bean id="mongoDbMessageStore" class="org.springframework.integration.mongodb.store.MongoDbMessageStore">
<constructor-arg ref="mongoDbFactory"/>
<para>
<programlisting lang="xml"><![CDATA[<bean id="mongoDbMessageStore" class="org.springframework.integration.mongodb.store.MongoDbMessageStore">
<constructor-arg ref="mongoDbFactory"/>
</bean>
<int:channel id="somePersistentQueueChannel">
@@ -97,11 +104,13 @@ For more information on how to configure please refer to
<int:aggregator input-channel="inputChannel" output-channel="outputChannel"
message-store="mongoDbMessageStore"/>]]></programlisting>
</para>
<para>
Above is a sample <classname>MongoDbMessageStore</classname> configuration as well as its usage (<emphasis>QueueChannel</emphasis> and <emphasis>Aggregator</emphasis>). As you can see it is a simple
bean configuration injected with <classname>SimpleMongoDbFactory</classname> via constructor.
</para>
</para>
<para>
Above is a sample <classname>MongoDbMessageStore</classname> configuration that shows its usage by a <emphasis>QueueChannel</emphasis>
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>
</section>
</chapter>

View File

@@ -186,13 +186,14 @@ rt.setConnectionFactory(redisConnectionFactory);]]></programlisting>
This can be very useful when dealing with components that have a capability to buffer messages
(<emphasis>QueueChannel, Aggregator, Resequencer</emphasis>, etc.) if reliability is a concern.
In Spring Integration, the MessageStore strategy also provides the foundation for the
<ulink url="http://www.eaipatterns.com/StoreInLibrary.html">ClaimCheck</ulink> pattern, described in EIP as well.
<ulink url="http://www.eaipatterns.com/StoreInLibrary.html">ClaimCheck</ulink> pattern, which is described in EIP as well.
</para>
<para>
Spring Integration's Redis module provides the <classname>RedisMessageStore</classname> which is an implementation of both the
MessageStore strategy (mainly used by the <emphasis>QueueChannel</emphasis> and <emphasis>ClaimCheck</emphasis> patterns) and
the <classname>MessageGroupStore</classname> strategy (mainly used by <emphasis>Aggregator</emphasis> and <emphasis>Resequencer</emphasis> patterns).
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
<emphasis>Resequencer</emphasis> patterns).
</para>
<para>