Spring Integration's current offering for "hooks" into the workings of a `Poller` are via the `advice-chain` which only allows a hook into `Callable.call()`. This however is a bit limited since it doesn't allow developers to be able to peak at the number of rows returned by the poller (that's done within the `Message<T> receive()` method).
I'm also aware that the `PollSkipAdvice` and `PollSkipStrategy` were introduced in 4.1 but they also do not allow for what I'm suggesting.
If you look at the [Polling Consumer](http://camel.apache.org/polling-consumer.html) of Apache Camel you'll notice that their Polling Consumer offers these options:
I'm proposing that the Spring team introduce a `org.springframework.integration.scheduling.PollingStrategy` interface that looks similar to this:
Attached is a class diagram of how the classes I envision might look. Items in yellow currently exist, items in blue are newly introduced. This is preliminary and is expected to be used to spark the conversation.
Following changes would need to be made:
|Callback to `PollingStrategy` for:
`Message<?> afterReceive(Message<?> returnValue)`
|`PollerMetadata`||Add `PollingStrategy` property.|
|`SourcePollingChannelAdapterFactoryBean`||If `PollerMetadata` contains `PollingStrategy` call these methods on that object:
`void setPollerMetadata(PollerMetadata pollerMetadata)`
`void setBoundResource(Object resourceToBind)`
Implementations of the `PollingStrategy` would vary but some initial ideas (these could be made more generic):
`VariousPollingFrequenciesBasedOnVolumePollingStrategy` (i.e. like a sliding-scale that would have different frequencies depending on different thresholds being met).
I have initial code I can share for the classes/interfaces in blue. Currently the hook into the framework however is via an `AfterReturningAdvice`.
Example of a configuration file in Spring Integration 4.1.1:
Example of same above configuration if the changes I'm proposing were adopted: