Class AdaptrisPollingConsumer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.AdaptrisPollingConsumer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
BaseJmsPollingConsumerImpl
,FsConsumerImpl
,FtpConsumerImpl
,PollingTrigger
public abstract class AdaptrisPollingConsumer extends AdaptrisMessageConsumerImp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
AdaptrisPollingConsumer.LockOperator
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description AdaptrisPollingConsumer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 thePoller
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-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageConsumer
consumeLocationKey
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.init()
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.start()
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- See Also:
ComponentLifecycle.stop()
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- See Also:
ComponentLifecycle.close()
-
continueProcessingMessages
public final boolean continueProcessingMessages(int currentCount)
Whether or not to continue processing messages.Concrete sub-classes should call this after processing each message before they start processing the next one.
- Returns:
- true if it's ok to carry on.
- See Also:
setReacquireLockBetweenMessages(Boolean)
,setMaxMessagesPerPoll(Integer)
-
releaseLock
protected void releaseLock()
-
processMessages
protected abstract int processMessages()
Implemented by protocol-specific sub-classes.
-
setReacquireLockBetweenMessages
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
.- Parameters:
b
- the lock flag
-
getReacquireLockBetweenMessages
public java.lang.Boolean getReacquireLockBetweenMessages()
Get the reacquire lock flag.
- Returns:
- true if the lock should be reacquired between messages
- See Also:
setReacquireLockBetweenMessages(Boolean)
-
getMaxMessagesPerPoll
public java.lang.Integer getMaxMessagesPerPoll()
-
setMaxMessagesPerPoll
public void setMaxMessagesPerPoll(java.lang.Integer max)
Set the maximum number of messages that should be processed in any one poll trigger.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.- Parameters:
max
- the max messages per poll, default is infinite if not specified.
-
getPoller
public Poller getPoller()
-
prepare
public final void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
prepareConsumer
protected abstract void prepareConsumer() throws CoreException
- Throws:
CoreException
-
-