INT-3339: Add priority to the JdbcChannelMS
JIRA: https://jira.spring.io/browse/INT-3339 INT-3339: Improve `priority` logic INT-3339: Add `MESSAGE_SEQUENCE` stuff INT-3339: Docs INT-3339: Polishing and PR comments INT-3339 Polishing Fix Oracle Test Case. Doc polishing.
This commit is contained in:
committed by
Gary Russell
parent
3f40c40641
commit
64a7a7e021
@@ -566,15 +566,16 @@ payload to an Integer.
|
||||
<code>message-store</code> attribute as shown in the next example.
|
||||
|
||||
<programlisting language="xml"><![CDATA[<int:channel id="dbBackedChannel">
|
||||
<int:queue message-store="messageStore"/>
|
||||
<int:queue message-store="channelStore"/>
|
||||
</int:channel>
|
||||
|
||||
<int-jdbc:message-store id="messageStore" data-source="someDataSource"/>]]></programlisting>
|
||||
<bean id="channelStore" class="o.s.i.jdbc.store.JdbcChannelMessageStore">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="channelMessageStoreQueryProvider" ref="queryProvider"/>
|
||||
</bean>]]></programlisting>
|
||||
|
||||
The above example also shows that <classname>JdbcMessageStore</classname> can be configured with the namespace support
|
||||
provided by the Spring Integration JDBC module. All you need to do is inject any <classname>javax.sql.DataSource</classname>
|
||||
instance. The Spring Integration JDBC module also provides schema DDL for most popular databases. These schemas are located in
|
||||
the <emphasis>org.springframework.integration.jdbc</emphasis> package of that module (spring-integration-jdbc).
|
||||
The Spring Integration JDBC module also provides schema DDL for a number of popular databases. These schemas are located in
|
||||
the <emphasis>org.springframework.integration.jdbc.store.channel</emphasis> package of that module (spring-integration-jdbc).
|
||||
|
||||
<important>
|
||||
One important feature is that with any transactional persistent store (e.g., JdbcChannelMessageStore), as long as the poller has a transaction configured,
|
||||
@@ -662,9 +663,12 @@ payload to an Integer.
|
||||
<para>
|
||||
Since <emphasis>version 4.0</emphasis>, the <code>priority-channel</code> child element supports
|
||||
the <code>message-store</code> option (<code>comparator</code> is not allowed in that case).
|
||||
The message store must be a <interfacename>ChannelPriorityMessageStore</interfacename> and, in this
|
||||
The message store must be a <interfacename>PriorityCapableChannelMessageStore</interfacename> and, in this
|
||||
case, the namespace parser will declare a <classname>QueueChannel</classname> instead of
|
||||
a <classname>PriorityChannel</classname>. See <xref linkend="channel-configuration-queuechannel"/>.
|
||||
a <classname>PriorityChannel</classname>. Implementations of the
|
||||
<classname>PriorityCapableChannelMessageStore</classname> are currently provided for <code>Redis</code>
|
||||
and <code>JDBC</code>.
|
||||
See <xref linkend="channel-configuration-queuechannel"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="channel-configuration-rendezvouschannel">
|
||||
|
||||
@@ -420,16 +420,12 @@
|
||||
<section id="jdbc-message-store-channels">
|
||||
<title>Backing Message Channels</title>
|
||||
<para>
|
||||
If you intent backing <emphasis>Message Channels</emphasis> using JDBC,
|
||||
If you intend backing <emphasis>Message Channels</emphasis> using JDBC,
|
||||
it is recommended to use the provided <classname>JdbcChannelMessageStore</classname>
|
||||
implementation instead. It can only be used in conjuntion
|
||||
implementation instead. It can only be used in conjunction
|
||||
with <emphasis>Message Channels</emphasis>.
|
||||
</para>
|
||||
<note>
|
||||
The provided <classname>JdbcChannelMessageStore</classname>
|
||||
implementation is available since <emphasis>Spring Integration 2.2.</emphasis>.
|
||||
</note>
|
||||
<para><emphasis>Supported Database</emphasis></para>
|
||||
<para><emphasis role="bold">Supported Databases</emphasis></para>
|
||||
<para>
|
||||
The <classname>JdbcChannelMessageStore</classname> uses database specific
|
||||
SQL queries to retrieve messages from the database. Therefore, users must
|
||||
@@ -451,19 +447,27 @@
|
||||
the <classname>AbstractChannelMessageStoreQueryProvider</classname>
|
||||
class and provide your own custom queries.
|
||||
</para>
|
||||
<para>
|
||||
Since <emphasis>version 4.0</emphasis>, the <code>MESSAGE_SEQUENCE</code> column has been
|
||||
added to the table to ensure first-in-first-out (FIFO) queueing even when messages are
|
||||
stored in the same millisecond.
|
||||
</para>
|
||||
<important>
|
||||
<para>
|
||||
Generally it is not recommened to use a relational database for the
|
||||
Generally it is not recommended to use a relational database for the
|
||||
purpose of queuing. Instead, if possible, consider using either JMS or
|
||||
AMQP, for which message store implementation are provided as well. For
|
||||
AMQP backed channels instead. For
|
||||
further reference please see the following resources:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem><ulink url="https://www.engineyard.com/blog/2011/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you/">5 subtle ways you’re using MySQL as a queue, and why it’ll bite you</ulink></listitem>
|
||||
<listitem><ulink url="http://mikehadlow.blogspot.com/2012/04/database-as-queue-anti-pattern.html">The Database As Queue Anti-Pattern</ulink></listitem>
|
||||
<listitem><ulink url=
|
||||
"https://www.engineyard.com/blog/2011/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you/"
|
||||
>5 subtle ways you’re using MySQL as a queue, and why it’ll bite you</ulink>.</listitem>
|
||||
<listitem><ulink url="http://mikehadlow.blogspot.com/2012/04/database-as-queue-anti-pattern.html"
|
||||
>The Database As Queue Anti-Pattern</ulink>.</listitem>
|
||||
</itemizedlist>
|
||||
</important>
|
||||
<para><emphasis>Concurrent Polling</emphasis></para>
|
||||
<para><emphasis role="bold">Concurrent Polling</emphasis></para>
|
||||
<para>
|
||||
When polling a <emphasis>Message Channel</emphasis>, you have the option
|
||||
to configure the associated <classname>Poller</classname> with a
|
||||
@@ -520,7 +524,46 @@
|
||||
|
||||
<int:channel id="outputChannel" />
|
||||
…]]></programlisting>
|
||||
<para>
|
||||
<emphasis role="bold">Priority Channel</emphasis>
|
||||
<para>
|
||||
Starting with <emphasis>version 4.0</emphasis>, the <classname>JdbcChannelMessageStore</classname>
|
||||
implements <interfacename>PriorityCapableChannelMessageStore</interfacename> and provides the
|
||||
<code>priorityEnabled</code> option allowing it to be used as a <code>message-store</code>
|
||||
reference for <code>priority-queue</code>s. For this purpose, the <code>INT_CHANNEL_MESSAGE</code>
|
||||
has a <code>MESSAGE_PRIORITY</code> column to store the value of <code>PRIORITY</code> Message header.
|
||||
In addition, a new <code>MESSAGE_SEQUENCE</code> column is also provided to achieve a robust first-in-first-out
|
||||
(FIFO) polling mechanism, even when multiple messages are stored with the same priority
|
||||
in the same millisecond. Messages are polled (selected) from the database with
|
||||
<code>order by MESSAGE_PRIORITY DESC NULLS LAST, CREATED_DATE, MESSAGE_SEQUENCE</code>.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It's not recommended to use the same <classname>JdbcChannelMessageStore</classname> bean
|
||||
for priority and non-priority queue channel, because <code>priorityEnabled</code> option applies to the
|
||||
entire store and proper FIFO queue semantics will not be retained for the queue channel.
|
||||
However the same <code>INT_CHANNEL_MESSAGE</code> table, and even <code>region</code>, can be used for both
|
||||
<classname>JdbcChannelMessageStore</classname> types. To configure that scenario, simply
|
||||
extend one message store bean from the other:
|
||||
</para>
|
||||
</note>
|
||||
<programlisting language="xml"><![CDATA[<bean id="channelStore" class="o.s.i.jdbc.store.JdbcChannelMessageStore">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="channelMessageStoreQueryProvider" ref="queryProvider"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="queueChannel">
|
||||
<int:queue message-store="store"/>
|
||||
</int:channel>
|
||||
|
||||
<bean id="priorityStore" parent="channelStore">
|
||||
<property name="priorityEnabled" value="true"/>
|
||||
</bean>
|
||||
|
||||
<int:channel id="priorityChannel">
|
||||
<int:priority-queue message-store="priorityStore"/>
|
||||
</int:channel>]]></programlisting>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Initializing the Database</title>
|
||||
|
||||
@@ -262,5 +262,14 @@
|
||||
<xref linkend="sftp-inbound"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="4.0-jdbc-cs">
|
||||
<title>JdbcChannelMessageStore and PriorityChannel</title>
|
||||
<para>
|
||||
The <classname>JdbcChannelMessageStore</classname> now implements
|
||||
<interfacename>PriorityCapableChannelMessageStore</interfacename>, allowing it to be used as
|
||||
a <code>message-store</code> reference for <code>priority-queue</code>s.
|
||||
For more information, see <xref linkend="jdbc-message-store-channels"/>.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user