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.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POLL_FREQUENCY |
static TimeUnit |
DEFAULT_POLL_TIMEUNIT |
static long |
DEFAULT_STARTUP_DELAY |
protected Map<ScheduledFuture,PollingReceiverWorker> |
schedules |
defaultInboundTransformers, defaultResponseTransformers, flowConstruct, listener, receiverKey, replyToHandler
connected, connector, endpoint, lifecycleManager, logger, muleMessageFactory, retryTemplate
PHASE_NAME
PHASE_NAME
PHASE_NAME
PHASE_NAME
Constructor and Description |
---|
AbstractPollingMessageReceiver(Connector connector,
FlowConstruct flowConstruct,
InboundEndpoint endpoint) |
Modifier and Type | Method and Description |
---|---|
protected PollingReceiverWorker |
createWork() |
void |
disableNativeScheduling() |
protected void |
doStart() |
protected void |
doStop() |
protected int |
getBatchSize(int available)
The preferred number of messages to process in the current batch.
|
long |
getFrequency() |
TimeUnit |
getTimeUnit() |
void |
performPoll()
Check whether polling should take place on this instance.
|
protected abstract void |
poll() |
protected boolean |
pollOnPrimaryInstanceOnly()
If this returns true for a transport, polling for that transport takes place only on the primary instance.
|
protected void |
schedule()
This method registers this receiver for periodic polling ticks with the connectors
scheduler.
|
void |
setFrequency(long value) |
void |
setTimeUnit(TimeUnit timeUnit) |
protected void |
unschedule()
This method cancels the schedules which were created in
schedule() . |
applyInboundTransformers, applyResponseTransformers, connectHandler, createExecutionTemplate, createLifecycleManager, createMuleEvent, doDispose, doStartHandler, getConnectEventId, getConnectionDescription, getEndpoint, getEndpointURI, getFlowConstruct, getReceiverKey, getReplyToHandler, getWorkManager, handleUnacceptedFilter, initialise, processMessage, propagateRootMessageIdProperty, routeEvent, routeMessage, routeMessage, routeMessage, routeMessage, routeMessage, setEndpoint, setListener, setReceiverKey, shouldConsumeInEveryNode, toString, warnIfMuleClientSendUsed
activate, connect, createMuleMessage, createMuleMessage, createMuleMessage, createMuleMessageFactory, createNullMuleMessage, disconnect, dispose, disposeAndLogException, doConnect, doDisconnect, doInitialise, getConnectEventId, getConnector, getLifecycleState, initializeMessageFactory, initializeRetryPolicy, isConnected, isDoThreading, isStarted, isStarting, isStopped, isStopping, passivate, setEndpoint, start, stop, validate, validateConnection
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createMuleMessage, createMuleMessage
connect, disconnect, isConnected, validateConnection
dispose
public static final long DEFAULT_POLL_FREQUENCY
public static final TimeUnit DEFAULT_POLL_TIMEUNIT
public static final long DEFAULT_STARTUP_DELAY
protected final Map<ScheduledFuture,PollingReceiverWorker> schedules
public AbstractPollingMessageReceiver(Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint) throws CreateException
CreateException
protected void doStart() throws MuleException
doStart
in class AbstractTransportMessageHandler
MuleException
protected void doStop() throws MuleException
doStop
in class AbstractMessageReceiver
MuleException
protected void schedule() throws RejectedExecutionException, NullPointerException, IllegalArgumentException
protected void unschedule()
schedule()
.Future.cancel(boolean)
public void disableNativeScheduling()
protected PollingReceiverWorker createWork()
public long getFrequency()
public void setFrequency(long value)
public TimeUnit getTimeUnit()
public void setTimeUnit(TimeUnit timeUnit)
protected int getBatchSize(int available)
available
- the number if messages currently available to be processedpublic final void performPoll() throws Exception
Exception
protected boolean pollOnPrimaryInstanceOnly()
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.