org.springframework.integration.dispatcher
Class DefaultPollingDispatcher

java.lang.Object
  extended by org.springframework.integration.dispatcher.SimpleDispatcher
      extended by org.springframework.integration.dispatcher.DefaultPollingDispatcher
All Implemented Interfaces:
MessageDispatcher, PollingDispatcher, Poller, Subscribable

public class DefaultPollingDispatcher
extends SimpleDispatcher
implements PollingDispatcher

A subclass of SimpleDispatcher that adds message retrieval capabilities by polling a PollableSource for Messages. The number of messages retrieved per poll is limited by the 'maxMessagesPerTask' property of the provided DispatcherPolicy, and the timeout for each receive call is determined by the policy's 'receiveTimeout' property. In general, it is recommended to use a value of 1 (the default) for 'maxMessagesPerTask' whenever a significant timeout is provided. Otherwise the poller may be holding on to available messages while waiting for additional messages. Note that the 'timeout' value is only relevant if the specified source is an implementation of BlockingSource. The default timeout value is 0 indicating that the method should return immediately rather than waiting for a Message to become available.

Author:
Mark Fisher

Field Summary
private  Source<?> source
           
 
Fields inherited from class org.springframework.integration.dispatcher.SimpleDispatcher
dispatcherPolicy, logger
 
Constructor Summary
DefaultPollingDispatcher(MessageChannel channel)
           
DefaultPollingDispatcher(Source<?> source, DispatcherPolicy dispatcherPolicy)
           
 
Method Summary
 boolean dispatch(Message<?> message)
           
 java.util.List<Message<?>> poll()
           
 
Methods inherited from class org.springframework.integration.dispatcher.SimpleDispatcher
setSendTimeout, subscribe, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.dispatcher.MessageDispatcher
setSendTimeout
 
Methods inherited from interface org.springframework.integration.message.Subscribable
subscribe, unsubscribe
 

Field Detail

source

private final Source<?> source
Constructor Detail

DefaultPollingDispatcher

public DefaultPollingDispatcher(MessageChannel channel)

DefaultPollingDispatcher

public DefaultPollingDispatcher(Source<?> source,
                                DispatcherPolicy dispatcherPolicy)
Method Detail

dispatch

public boolean dispatch(Message<?> message)
Specified by:
dispatch in interface MessageDispatcher
Overrides:
dispatch in class SimpleDispatcher

poll

public java.util.List<Message<?>> poll()
Specified by:
poll in interface Poller