diff --git a/docs/src/reference/docbook/channel-adapter.xml b/docs/src/reference/docbook/channel-adapter.xml index b67cad2ccf..8e2042246f 100644 --- a/docs/src/reference/docbook/channel-adapter.xml +++ b/docs/src/reference/docbook/channel-adapter.xml @@ -35,6 +35,50 @@ See for more detail. + + Poller Configuration + + Some inbound-channel-adapter types are backed by a SourcePollingChannelAdapter which + means they contain Poller configuration which will poll the MessageSource (invoke a custom method + which produces the value that becomes a Message payload) based on the configuration + specified in the Poller. + + For example: + + + +]]> + 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 + max-messages-per-poll 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: + ]]> + Note there is no max-messages-per-poll specified. As you'll learn later the identical poller configuration + in the PollingConsumer (e.g., service-activator, filter, router etc.) would have a default + value of -1 for max-messages-per-poll 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. + + + However in the SourcePollingChannelAdapter it is a bit different. + The default value for max-messages-per-poll 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 MessageSource is not interruptible. In other words when executing stop() method + of the poller (e.g., SourcePollingChannelAdapter.stop()) the interrupt signal will be sent to the + TaskExecutor but if poller is executing method that is not interruptible, + the poller will never shut down. + + + 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 max-messages-per-poll + to negative value. + ]]> + + + +