public abstract class AdaptrisPollingConsumer extends AdaptrisMessageConsumerImp
Modifier and Type | Class and Description |
---|---|
protected static interface |
AdaptrisPollingConsumer.LockOperator |
log
Constructor and Description |
---|
AdaptrisPollingConsumer() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the component.
|
boolean |
continueProcessingMessages(int currentCount)
Whether or not to continue processing messages.
|
java.lang.Integer |
getMaxMessagesPerPoll() |
Poller |
getPoller() |
java.lang.Boolean |
getReacquireLockBetweenMessages()
Get the reacquire lock flag.
|
void |
init()
Initialises the component.
|
void |
prepare()
Prepare for initialisation.
|
protected abstract void |
prepareConsumer() |
protected abstract int |
processMessages()
Implemented by protocol-specific sub-classes.
|
protected void |
releaseLock() |
void |
setMaxMessagesPerPoll(java.lang.Integer max)
Set the maximum number of messages that should be processed in any one poll trigger.
|
void |
setPoller(Poller s)
Set the
Poller to use. |
void |
setReacquireLockBetweenMessages(java.lang.Boolean b)
Specify whether concrete sub-classes should attempt to reacquire the lock in between processing messages.
|
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
consumeLocationKey
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
CoreException
- wrapping any underlying Exception
sComponentLifecycle.start()
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
ComponentLifecycle.stop()
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
ComponentLifecycle.close()
public final boolean continueProcessingMessages(int currentCount)
Concrete sub-classes should call this after processing each message before they start processing the next one.
setReacquireLockBetweenMessages(Boolean)
,
setMaxMessagesPerPoll(Integer)
protected void releaseLock()
protected abstract int processMessages()
Implemented by protocol-specific sub-classes.
public void setReacquireLockBetweenMessages(java.lang.Boolean b)
Specify whether concrete sub-classes should attempt to reacquire the lock in between processing messages. Releasing then
attemtping to reqcquire the log gives other threads an opportunity to obtain the lock. This is significant in high volume
environments, particularly where messages are not processed in discreet batches e.g. JmsPollingConsumer
.
b
- the lock flagpublic java.lang.Boolean getReacquireLockBetweenMessages()
Get the reacquire lock flag.
setReacquireLockBetweenMessages(Boolean)
public java.lang.Integer getMaxMessagesPerPoll()
public void setMaxMessagesPerPoll(java.lang.Integer max)
It can be arbitrarily useful to limit the number of messages processed per poll. For instance, you are using
QuartzCronPoller
and you need to ensure a time period when no activity occurs. In the event that a large number of
documents are ready to process just before the no-activity-time; then without a maximum the adapter will continue processing
until all documents are handled.
max
- the max messages per poll, default is infinite if not specified.public Poller getPoller()
public final void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
protected abstract void prepareConsumer() throws CoreException
CoreException