org.mule.transport
Class AbstractPollingMessageReceiver
java.lang.Object
org.mule.transport.AbstractTransportMessageHandler
org.mule.transport.AbstractMessageReceiver
org.mule.transport.AbstractPollingMessageReceiver
- All Implemented Interfaces:
- Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable, MessageSource, Connectable, MessageReceiver
- Direct Known Subclasses:
- FileMessageReceiver, FtpMessageReceiver, MessageProcessorPollingMessageReceiver, PollingHttpMessageReceiver, PollingTcpMessageReceiver, RetrieveMessageReceiver, RmiMessageReceiver, SftpMessageReceiver, StdioMessageReceiver, TransactedPollingMessageReceiver, XmppPollingMessageReceiver
public abstract class AbstractPollingMessageReceiver
- extends AbstractMessageReceiver
AbstractPollingMessageReceiver
implements a base class for polling
message receivers. The receiver provides a poll()
method that implementations
must implement to execute their custom code. Note that the receiver will not poll if
the associated connector is not started.
Methods inherited from class org.mule.transport.AbstractMessageReceiver |
applyInboundTransformers, applyResponseTransformers, createExecutionTemplate, createLifecycleManager, createMuleEvent, doDispose, getConnectEventId, getConnectionDescription, getEndpoint, getEndpointURI, getFlowConstruct, getReceiverKey, getReplyToHandler, getWorkManager, handleUnacceptedFilter, initialise, propagateRootMessageIdProperty, routeMessage, routeMessage, routeMessage, routeMessage, routeMessage, setEndpoint, setListener, setReceiverKey, toString, warnIfMuleClientSendUsed |
Methods inherited from class org.mule.transport.AbstractTransportMessageHandler |
activate, connect, createMuleMessage, createMuleMessage, createMuleMessage, createMuleMessageFactory, createNullMuleMessage, disconnect, dispose, disposeAndLogException, doConnect, doDisconnect, doInitialise, getConnectEventId, getConnector, getLifecycleState, initializeMessageFactory, initializeRetryPolicy, isConnected, isDoThreading, isStarted, isStarting, isStopping, passivate, setEndpoint, start, stop, validate, validateConnection |
Methods inherited from interface org.mule.api.lifecycle.Startable |
start |
Methods inherited from interface org.mule.api.lifecycle.Stoppable |
stop |
DEFAULT_POLL_FREQUENCY
public static final long DEFAULT_POLL_FREQUENCY
- See Also:
- Constant Field Values
DEFAULT_POLL_TIMEUNIT
public static final TimeUnit DEFAULT_POLL_TIMEUNIT
DEFAULT_STARTUP_DELAY
public static final long DEFAULT_STARTUP_DELAY
- See Also:
- Constant Field Values
schedules
protected final Map<ScheduledFuture,PollingReceiverWorker> schedules
AbstractPollingMessageReceiver
public AbstractPollingMessageReceiver(Connector connector,
FlowConstruct flowConstruct,
InboundEndpoint endpoint)
throws CreateException
- Throws:
CreateException
doStart
protected void doStart()
throws MuleException
- Overrides:
doStart
in class AbstractTransportMessageHandler
- Throws:
MuleException
doStop
protected void doStop()
throws MuleException
- Overrides:
doStop
in class AbstractTransportMessageHandler
- Throws:
MuleException
schedule
protected void schedule()
throws RejectedExecutionException,
NullPointerException,
IllegalArgumentException
- This method registers this receiver for periodic polling ticks with the connectors
scheduler. Subclasses can override this in case they want to handle their polling
differently.
- Throws:
RejectedExecutionException
NullPointerException
IllegalArgumentException
- See Also:
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit)
unschedule
protected void unschedule()
- This method cancels the schedules which were created in
schedule()
.
- See Also:
Future.cancel(boolean)
disableNativeScheduling
public void disableNativeScheduling()
createWork
protected PollingReceiverWorker createWork()
getFrequency
public long getFrequency()
setFrequency
public void setFrequency(long value)
getTimeUnit
public TimeUnit getTimeUnit()
setTimeUnit
public void setTimeUnit(TimeUnit timeUnit)
getBatchSize
protected int getBatchSize(int available)
- The preferred number of messages to process in the current batch. We need to
drain the queue quickly, but not by slamming the workManager too hard. It is
impossible to determine this more precisely without proper load
statistics/feedback or some kind of "event cost estimate". Therefore we just
try to use half of the receiver's workManager, since it is shared with
receivers for other endpoints. TODO make this user-settable
- Parameters:
available
- the number if messages currently available to be processed
performPoll
public final void performPoll()
throws Exception
- Check whether polling should take place on this instance.
- Throws:
Exception
pollOnPrimaryInstanceOnly
protected boolean pollOnPrimaryInstanceOnly()
- If this returns true for a transport, polling for that transport takes place only on the primary instance.
poll
protected abstract void poll()
throws Exception
- Throws:
Exception
Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.