INT-1853 added documentation about poller configuration

This commit is contained in:
Oleg Zhurakousky
2011-05-03 23:22:55 -04:00
parent 765503daa4
commit c87a34c820

View File

@@ -35,6 +35,50 @@
See <xref linkend="endpoint-namespace"/> for more detail.
</para>
</note>
<important>
<para><emphasis>Poller Configuration</emphasis> </para>
<para>
Some <code>inbound-channel-adapter</code> types are backed by a <classname>SourcePollingChannelAdapter</classname> which
means they contain Poller configuration which will poll the <classname>MessageSource</classname> (invoke a custom method
which produces the value that becomes a <classname>Message</classname> payload) based on the configuration
specified in the Poller.
</para>
<para>For example:
<programlisting language="xml"><![CDATA[<poller max-messages-per-poll="1" fixed-rate="1000"/>
<poller max-messages-per-poll="10" fixed-rate="1000"/>]]></programlisting>
In the the first configuration the polling task will be invoked once per poll and during such task (poll)
the method (which results in the production of the Message) will be invoked once based on the
<code>max-messages-per-poll</code> attribute value. In the second configuration the polling task will be invoked
10 times per poll or until it returns 'null' thus possibly producing 10 Messages per poll while each poll happens
at 1 second intervals.
However what if the configuration looks like this:
<programlisting language="xml"><![CDATA[<poller fixed-rate="1000"/>]]></programlisting>
Note there is no <code>max-messages-per-poll</code> specified. As you'll learn later the identical poller configuration
in the <classname>PollingConsumer</classname> (e.g., service-activator, filter, router etc.) would have a default
value of -1 for <code>max-messages-per-poll</code> which means "execute poling task non-stop unless polling method
returns null (e.g., no more Messages in the QueueChannel)" and then sleep for 1 second.
</para>
<para>
However in the SourcePollingChannelAdapter it is a bit different.
The default value for <code>max-messages-per-poll</code> will be set to 1 by default unless you explicitly set it to
a negative value (e.g., -1). It is done so to make sure that poller can react to a LifeCycle events (e.g., start/stop)
and prevent it from potentially spinning in the non-interruptible infinite loop if the implementation of the custom
method of the <classname>MessageSource</classname> is not interruptible. In other words when executing stop() method
of the poller (e.g., <code>SourcePollingChannelAdapter.stop()</code>) the interrupt signal will be sent to the
<classname>TaskExecutor</classname> but if poller is executing method that is not interruptible,
the poller will never shut down.
</para>
<para>
However if you are sure that your method is interruptible and you need the behavior where your want to poll
for as many sources as available per each poll, then you should explicitly set <code>max-messages-per-poll</code>
to negative value.
<programlisting language="xml"><![CDATA[<poller max-messages-per-poll="-1" fixed-rate="1000"/>]]></programlisting>
</para>
</important>
</section>
<section id="channel-adapter-namespace-outbound">