org.springframework.integration.dispatcher
Class PollingDispatcher

java.lang.Object
  extended by org.springframework.integration.dispatcher.PollingDispatcher
All Implemented Interfaces:
java.lang.Runnable, SchedulableTask
Direct Known Subclasses:
EndpointTrigger

public class PollingDispatcher
extends java.lang.Object
implements SchedulableTask

Author:
Mark Fisher

Field Summary
private  MessageDispatcher dispatcher
           
private  int maxMessagesPerTask
           
private  long receiveTimeout
           
private  Schedule schedule
           
private  MessageSource<?> source
           
 
Constructor Summary
PollingDispatcher(MessageSource<?> source, MessageDispatcher dispatcher, Schedule schedule)
          Create a PollingDispatcher for the provided MessageSource.
 
Method Summary
 boolean addTarget(MessageTarget target)
           
private  boolean dispatch()
           
 Schedule getSchedule()
           
 boolean removeTarget(MessageTarget target)
           
 void run()
           
 void setMaxMessagesPerTask(int maxMessagesPerTask)
          Set the maximum number of messages to receive for each poll.
 void setReceiveTimeout(long receiveTimeout)
          Specify the timeout to use when receiving from the source (in milliseconds).
 void setSendTimeout(long sendTimeout)
          Specify the timeout to use when sending to a target (in milliseconds).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

private final MessageSource<?> source

dispatcher

private final MessageDispatcher dispatcher

schedule

private final Schedule schedule

receiveTimeout

private volatile long receiveTimeout

maxMessagesPerTask

private volatile int maxMessagesPerTask
Constructor Detail

PollingDispatcher

public PollingDispatcher(MessageSource<?> source,
                         MessageDispatcher dispatcher,
                         Schedule schedule)
Create a PollingDispatcher for the provided MessageSource. It can be scheduled according to the specified Schedule.

Method Detail

setReceiveTimeout

public void setReceiveTimeout(long receiveTimeout)
Specify the timeout to use when receiving from the source (in milliseconds). Note that this value will only be applicable if the source is an instance of BlockingSource.

A negative value indicates that receive calls should block indefinitely. The default value is 5000 (5 seconds).


setSendTimeout

public void setSendTimeout(long sendTimeout)
Specify the timeout to use when sending to a target (in milliseconds). Note that this value will only be applicable if the target is an instance of BlockingTarget. The default value is 0.


setMaxMessagesPerTask

public void setMaxMessagesPerTask(int maxMessagesPerTask)
Set the maximum number of messages to receive for each poll. A non-positive value indicates that polling should repeat as long as non-null messages are being received and successfully sent.


addTarget

public boolean addTarget(MessageTarget target)

removeTarget

public boolean removeTarget(MessageTarget target)

getSchedule

public Schedule getSchedule()
Specified by:
getSchedule in interface SchedulableTask

run

public void run()
Specified by:
run in interface java.lang.Runnable

dispatch

private boolean dispatch()