INT-1455, modified documentation to reflect changes to the poller configuration, added section on advice-chains configuration for pollers

This commit is contained in:
Oleg Zhurakousky
2010-09-15 21:08:38 -04:00
parent d9671c6cf1
commit 7d2d8c28a3
11 changed files with 62 additions and 75 deletions

View File

@@ -37,9 +37,7 @@
<interfacename>PollableChannel</interfacename> to a <interfacename>SubscribableChannel</interfacename>, and when
performing this role, the Messaging Bridge may also serve as a throttler:
<programlisting language="xml"><![CDATA[ <bridge input-channel="pollable" output-channel="subscribable">
<poller max-messages-per-poll="10">
<interval-trigger interval="5" time-unit="SECONDS"/>
</poller>
<poller max-messages-per-poll="10" fixed-rate="5000"/>
</bridge>]]></programlisting>
</para>
<para>

View File

@@ -22,15 +22,11 @@
provide a 'poller' element with either an 'interval-trigger' (in milliseconds) or 'cron-trigger'
sub-element.
<programlisting language="xml"><![CDATA[<inbound-channel-adapter ref="source1" method="method1" channel="channel1">
<poller>
<interval-trigger interval="5000"/>
</poller>
<poller fixed-rate="5000"/>
</inbound-channel-adapter>
<inbound-channel-adapter ref="source2" method="method2" channel="channel2">
<poller>
<cron-trigger expression="30 * 9-17 * * MON-FRI"/>
</poller>
<poller cron="30 * 9-17 * * MON-FRI"/>
</channel-adapter>]]></programlisting>
</para>
<note>
@@ -49,9 +45,8 @@
<programlisting language="xml"><![CDATA[<outbound-channel-adapter channel="channel1" ref="target1" method="method1"/>]]></programlisting>
If the channel being adapted is a <interfacename>PollableChannel</interfacename>, provide a poller sub-element:
<programlisting language="xml"><![CDATA[<outbound-channel-adapter channel="channel2" ref="target2" method="method2">
]]><emphasis><![CDATA[<poller>
<interval-trigger interval="3000"/>
</poller>]]></emphasis><![CDATA[
]]><emphasis><![CDATA[<poller fixed-rate="3000"/>
]]></emphasis><![CDATA[
</outbound-channel-adapter>
<beans:bean id="target1" class="org.bar.Foo"/>
]]></programlisting>

View File

@@ -166,32 +166,33 @@ consumer.setTransactionManager(txManager);</programlisting>
<classname>EventDrivenConsumer</classname> depending on the type of the "input-channel" that is
referenced: <interfacename>PollableChannel</interfacename> or <interfacename>SubscribableChannel</interfacename>
respectively. When the channel is pollable, then the polling behavior is determined based on the endpoint
element's "poller" sub-element. For example, a simple interval-based poller with a 1-second interval would be
element's "poller" sub-element and its attributes. For example, a simple interval-based poller with a 1-second interval would be
configured like this: <programlisting language="xml"><![CDATA[ <transformer input-channel="pollable"
ref="transformer"
output-channel="output">
<poller>
<interval-trigger interval="1000"/>
</poller>
<poller fixed-rate="1000"/>
</transformer>]]></programlisting>
For a poller based on a Cron expression, use the "cron-trigger" child element instead:
As an alternative to 'fixed-rate' you cna also use 'fixed-delay' attribute.
</para>
<para>
For a poller based on a Cron expression, use the "cron" attribute instead:
<programlisting language="xml"><![CDATA[ <transformer input-channel="pollable"
ref="transformer"
output-channel="output">
<poller>
<cron-trigger expression="*/10 * * * * MON-FRI"/>
</poller>
<poller cron="*/10 * * * * MON-FRI"/>
</transformer>]]></programlisting>
</para>
<para>
If the input channel is a <interfacename>PollableChannel</interfacename>, then the poller configuration is
required. Specifically, as mentioned above, the 'trigger' is a required property of the PollingConsumer class.
Therefore, if you omit the "poller" sub-element for a Polling Consumer endpoint's configuration, an Exception
may be thrown. However, it is also possible to create top-level pollers in which case only a "ref" is required:
<programlisting language="xml"><![CDATA[ <poller id="weekdayPoller">
<cron-trigger expression="*/10 * * * * MON-FRI"/>
</poller>
may be thrown. The exception will also be thrown if you attempt to configure a poller on the element that is
connected to a non-pollable channel.
</para>
<para>
It is also possible to create top-level pollers in which case only a "ref" is required:
<programlisting language="xml"><![CDATA[ <poller id="weekdayPoller" cron="*/10 * * * * MON-FRI"/>
<transformer input-channel="pollable"
ref="transformer"
output-channel="output">
@@ -201,10 +202,8 @@ consumer.setTransactionManager(txManager);</programlisting>
an ApplicationContext may have the <code>default</code> attribute with a value of "true". In that case, any
endpoint with a PollableChannel for its input-channel that is defined within the same ApplicationContext and has
no explicitly configured 'poller' sub-element will use that default.
<programlisting language="xml"><![CDATA[ <poller id="defaultPoller" default="true" max-messages-per-poll="5">
<interval-trigger interval="3" time-unit="SECONDS"/>
</poller>
<programlisting language="xml"><![CDATA[ <poller id="defaultPoller" default="true" max-messages-per-poll="5" fixed-rate="3000"/>
<!-- No <poller/> sub-element is necessary since there is a default -->
<transformer input-channel="pollable"
ref="transformer"
@@ -215,14 +214,36 @@ consumer.setTransactionManager(txManager);</programlisting>
operation can be performed as an atomic unit-of-work. To configure transactions for a poller, simply add the
&lt;transactional/&gt; sub-element. The attributes for this element should be familiar to anyone who has
experience with Spring's Transaction management:
<programlisting language="xml"><![CDATA[<poller>
<interval-trigger interval="1000"/>
<programlisting language="xml"><![CDATA[<poller fixed-delay="1000">
<transactional transaction-manager="txManager"
propagation="REQUIRED"
isolation="REPEATABLE_READ"
timeout="10000"
read-only="false"/>
</poller>]]></programlisting>
</para>
<para>
<emphasis>AOP Advice chains</emphasis>
</para>
<para>
Since Spring transaction support depends on the Proxy mechanism  with <classname>TransactionInterceptor</classname> (AOP Advice) handling transactional
behavior of the message flow initiated by the poler, some times there is a need to provide extra Advice(s) to handle other
cross cutting behavior associated with the poller. For that poller defines an 'advice-chain' element allowing you to add
more advices - class that  implements <classname>MethodInterceptor</classname> interface.. 
<programlisting language="xml"><![CDATA[<service-activator id="advicedSa" input-channel="goodInputWithAdvice" ref="testBean"
method="good" output-channel="output">
<poller max-messages-per-poll="1" fixed-rate="10000">
<transactional transaction-manager="txManager" />
<advice-chain>
<ref bean="adviceA" />
<beans:bean class="org.bar.SampleAdvice"/>
</advice-chain>
</poller>
</service-activator>]]></programlisting>
For more information on how to implement MethodInterceptor please refer to AOP sections of Spring
reference manual (section 7 and 8). Advice chain can also be applied on the poller that does not have
any transaction configuration essentially allowing you to enhance the behavior of the message flow initiated by the poller.
</para>
<para>
The polling threads may be executed by any instance of Spring's <interfacename>TaskExecutor</interfacename>
@@ -234,10 +255,8 @@ consumer.setTransactionManager(txManager);</programlisting>
(the other major factor being the expected volume on the channel to which the endpoint subscribes). To enable
concurrency for a polling endpoint that is configured with the XML namespace support, provide the 'task-executor'
reference on its &lt;poller/&gt; element and then provide one or more of the properties shown below:
<programlisting language="xml"><![CDATA[ <poller task-executor="pool"/>
<interval-trigger interval="5" time-unit="SECONDS"/>
</poller>
<programlisting language="xml"><![CDATA[ <poller task-executor="pool" fixed-rate="1000"/>
<task:executor id="pool"
pool-size="5-25"
queue-capacity="20"
@@ -260,14 +279,12 @@ consumer.setTransactionManager(txManager);</programlisting>
instantaneously.
<programlisting language="xml"><![CDATA[ <service-activator input-channel="someQueueChannel"
output-channel="output">
<poller receive-timeout="30000">
<interval-trigger interval="10"/>
</poller>
<poller receive-timeout="30000" fixed-rate="10"/>
</service-activator>]]></programlisting>
Using this approach does not carry much overhead since internally it is nothing more then a timed-wait thread
which does not require nearly as much CPU resource usage as a thrashing, infinite while loop for example.
</para>
</section>
<section id="payload-type-conversion">

View File

@@ -51,9 +51,7 @@ If you are using PollableChannel (e.g., Queue), you can also provide <emphasis>p
</int:channel>
<int-event:outbound-channel-adapter channel="input">
<int:poller max-messages-per-poll="1" task-executor="executor">
<int:interval-trigger interval="100" time-unit="MILLISECONDS"/>
</int:poller>
<int:poller max-messages-per-poll="1" task-executor="executor" fixed-rate="100"/>
</int-event:outbound-channel-adapter>
<task:executor id="executor" pool-size="5"/>]]></programlisting>

View File

@@ -60,8 +60,7 @@
<programlisting>&lt;jdbc:inbound-channel-adapter query="..."
channel="target" data-source="dataSource"
update="..."&gt;
&lt;poller&gt;
&lt;interval-trigger interval="1000"/&gt;
&lt;poller fixed-rate"1000"&gt;
&lt;transactional/&gt;
&lt;/poller&gt;
&lt;/jdbc:inbound-channel-adapter&gt;</programlisting>

View File

@@ -28,9 +28,7 @@
(a 'destinationName' can be provided in place of the 'destination' reference). The following example defines an
inbound Channel Adapter with a <classname>Destination</classname> reference.
<programlisting language="xml"><![CDATA[ <jms:inbound-channel-adapter id="jmsIn" destination="inQueue" channel="exampleChannel">
<integration:poller>
<integration:interval-trigger interval="30" time-unit="SECONDS"/>
</integration:poller>
<integration:poller fixed-rate="30000"/>
</jms:inbound-channel-adapter>]]></programlisting>
<tip>
Notice from the configuration that the inbound-channel-adapter is a Polling Consumer. That means that
@@ -56,9 +54,7 @@
destination="inQueue"
channel="exampleChannel"
extract-payload="false"/>
<integration:poller>
<integration:interval-trigger interval="30" time-unit="SECONDS"/>
</integration:poller>
<integration:poller fixed-rate="30000"/>
</jms:inbound-channel-adapter>]]></programlisting>
</para>
</section>

View File

@@ -89,9 +89,7 @@
channel="channel"
object-name="example.domain:name=someService"
attribute-name="InvocationCount"&gt;
&lt;si:poller max-messages-per-poll="1"&gt;
&lt;si:interval-trigger interval="5000"/&gt;
&lt;/si:poller&gt;
&lt;si:poller max-messages-per-poll="1" fixed-rate="5000"/&gt;
&lt;/jmx:attribute-polling-channel-adapter&gt;
</programlisting></para>
</section>

View File

@@ -99,9 +99,7 @@
should-delete-messages="true"
should-mark-messages-as-read="true"
auto-startup="true">
<int:poller max-messages-per-poll="1">
<int:interval-trigger interval="5000"/>
</int:poller>
<int:poller max-messages-per-poll="1" fixed-rate="5000"/>
</int-mail:inbound-channel-adapter>]]></programlisting>
If you do have IMAP idle support, then you may want to configure the "imap-idle-channel-adapter" element instead.
Since the "idle" command enables event-driven notifications, no poller is necessary for this adapter. It will

View File

@@ -93,9 +93,7 @@
<beans:bean id="waiter" class="org.springframework.integration.samples.cafe.xml.Waiter"/>
<poller id="poller" default="true">
<interval-trigger interval="1000"/>
</poller>
<poller id="poller" default="true" fixed-rate="1000"/>
</beans:beans>]]></programlisting>
As you can see, each Message Endpoint is connected to input and/or output channels. Each endpoint will manage
@@ -221,9 +219,8 @@
ref="barista"
method="prepareHotDrink"
output-channel="preparedDrinks">
]]><emphasis><![CDATA[<poller task-executor="pool">
<interval-trigger interval="1000"/>
</poller>]]></emphasis><![CDATA[
]]><emphasis><![CDATA[<poller task-executor="pool" fixed-rate="1000"/>
]]></emphasis><![CDATA[
</service-activator>
]]><emphasis><![CDATA[<task:executor id="pool" pool-size="5"/>]]></emphasis></programlisting>

View File

@@ -140,9 +140,7 @@
input-channel="input"
output-channel="output"
unmarshaller="unmarshaller">
<si:poller>
<si:interval-trigger interval="2000"/>
</si:poller>
<si:poller fixed-rate="2000"/>
<si-xml:unmarshalling-transformer/>
]]></programlisting>
</para>
@@ -386,9 +384,7 @@
output-channel="orderItemsChannel"
create-documents="true">
<si-xml:xpath-expression expression="/order/items"/>
<si:poller>
<si:interval-trigger interval="2000"/>
</si:poller>
<si:poller fixed-rate="2000"/>
</si-xml:xpath-splitter>]]></programlisting>
</para>
<para>
@@ -403,9 +399,7 @@
<!-- route the order to all responders-->
<si-xml:xpath-router id="responderRouter" input-channel="orderChannel" multi-channel="true">
<si-xml:xpath-expression expression="/request/responders"/>
<si:poller>
<si:interval-trigger interval="2000"/>
</si:poller>
<si:poller fixed-rate="2000"/>
</si-xml:xpath-router>]]></programlisting>
</para>
</section>

View File

@@ -276,10 +276,7 @@ public class XmppMessageConsumer {
class="com.myxmppproducer.outbound.XmppMessageProducer"
p:recipient="${user.2.login}"/>
<poller default="true">
<interval-trigger fixed-rate="true"
interval="10" time-unit="SECONDS"/>
</poller>
<poller default="true" fixed-rate="10000"/>
<xmpp:xmpp-connection
id="testConnection"