public abstract class JmsPollingConsumerImpl extends AdaptrisPollingConsumer implements JmsActorConfig, JmsConnectionConfig
AdaptrisPollingConsumer
for queues and topics.
The behaviour of this consumer differs from the standard JmsConsumerImpl
concrete
implementations. This consumer has the following steps.
Message
within the given getReceiveTimeout()
.
javax.jms.Message
and repeats until no more messages.If connection attempt fails, the poller sleeps for the configured interval then tries again.
AdaptrisPollingConsumer.LockOperator
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
JmsPollingConsumerImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
additionalDebug() |
void |
close()
Closes the component.
|
int |
configuredAcknowledgeMode()
Return the current acknowledge mode.
|
java.lang.String |
configuredClientId()
The client id.
|
CorrelationIdSource |
configuredCorrelationIdSource()
Return the current correlation id source.
|
AdaptrisMessageListener |
configuredMessageListener()
return the current configured MessageListener.
|
MessageTypeTranslator |
configuredMessageTranslator()
Return the currently configured messageTranslator.
|
java.lang.String |
configuredPassword()
The password.
|
java.lang.String |
configuredUserName()
The username.
|
VendorImplementation |
configuredVendorImplementation()
The vendor specific implementation.
|
java.lang.String |
consumeLocationKey()
Provides the metadata key "JMSDestination" which
will only be populated if
MessageTypeTranslatorImp.getMoveJmsHeaders() is true. |
protected javax.jms.ConnectionFactory |
createConnectionFactory() |
protected abstract javax.jms.MessageConsumer |
createConsumer() |
protected javax.jms.Session |
createSession(javax.jms.Connection connection,
int acknowledgeMode,
boolean transacted) |
org.slf4j.Logger |
currentLogger()
Return the configured logger.
|
javax.jms.Session |
currentSession()
Return the current jms session.
|
java.lang.String |
getAcknowledgeMode() |
java.lang.Boolean |
getAdditionalDebug() |
java.lang.String |
getClientId() |
CorrelationIdSource |
getCorrelationIdSource()
Returns correlationIdSource.
|
MessageTypeTranslator |
getMessageTranslator() |
java.lang.String |
getPassword() |
TimeInterval |
getReceiveTimeout() |
java.lang.String |
getUserName() |
VendorImplementation |
getVendorImplementation() |
void |
init()
Initialises the component.
|
boolean |
isManagedTransaction() |
void |
prepareConsumer() |
protected int |
processMessages()
Implemented by protocol-specific sub-classes.
|
long |
rollbackTimeout()
How long we should wait after a rollback before continuing on with
processing
|
void |
setAcknowledgeMode(java.lang.String s)
Sets the JMS acknowledge mode to use.
|
void |
setAdditionalDebug(java.lang.Boolean b) |
void |
setClientId(java.lang.String s)
Sets the optional JMS client ID.
|
void |
setCorrelationIdSource(CorrelationIdSource c)
Sets correlationIdSource.
|
void |
setManagedTransaction(boolean managedTransaction) |
void |
setMessageTranslator(MessageTypeTranslator m) |
void |
setPassword(java.lang.String s)
Sets the password for the specified user.
|
void |
setReceiveTimeout(TimeInterval l)
Sets the period that this class should wait for the broker to deliver a message.
|
void |
setUserName(java.lang.String s) |
void |
setVendorImplementation(VendorImplementation v) |
continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
changeState, getDestination, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
public void prepareConsumer() throws CoreException
prepareConsumer
in class AdaptrisPollingConsumer
CoreException
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class AdaptrisPollingConsumer
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
protected javax.jms.ConnectionFactory createConnectionFactory() throws java.lang.Exception
java.lang.Exception
protected javax.jms.Session createSession(javax.jms.Connection connection, int acknowledgeMode, boolean transacted) throws javax.jms.JMSException
javax.jms.JMSException
protected abstract javax.jms.MessageConsumer createConsumer() throws javax.jms.JMSException
javax.jms.JMSException
protected int processMessages()
AdaptrisPollingConsumer
Implemented by protocol-specific sub-classes.
processMessages
in class AdaptrisPollingConsumer
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
close
in interface ComponentLifecycle
close
in class AdaptrisPollingConsumer
ComponentLifecycle.close()
public java.lang.String getAcknowledgeMode()
public void setAcknowledgeMode(java.lang.String s)
Sets the JMS acknowledge mode to use.
The value may be AUTO_KNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE or the int values corresponding to the JMS Session Constant
s
- the JMS acknowledge mode to usepublic java.lang.String getClientId()
public void setClientId(java.lang.String s)
Sets the optional JMS client ID. May not be empty, null means don't use client ID.
s
- the optional JMS client ID, defaults to null.public MessageTypeTranslator getMessageTranslator()
public void setMessageTranslator(MessageTypeTranslator m)
public java.lang.String getPassword()
public void setPassword(java.lang.String s)
Sets the password for the specified user.
In additional to plain text passwords, the passwords can also be encrypted
using the appropriate Password
s
- the password for the specified userpublic java.lang.String getUserName()
public void setUserName(java.lang.String s)
public VendorImplementation getVendorImplementation()
public void setVendorImplementation(VendorImplementation v)
public TimeInterval getReceiveTimeout()
public void setReceiveTimeout(TimeInterval l)
The default value of 2 seconds should be suitable in most situations. If there is a high degree of network latency and this class does not consume messages from Queues / Topics as expected try setting a higher value.
l
- the period that this class should wait for the broker to deliver a message, if < 0 then the default (2secs) will be
used.public CorrelationIdSource getCorrelationIdSource()
Returns correlationIdSource.
public void setCorrelationIdSource(CorrelationIdSource c)
Sets correlationIdSource.
c
- the correlationIdSource to setpublic CorrelationIdSource configuredCorrelationIdSource()
JmsActorConfig
configuredCorrelationIdSource
in interface JmsActorConfig
public MessageTypeTranslator configuredMessageTranslator()
JmsActorConfig
configuredMessageTranslator
in interface JmsActorConfig
public int configuredAcknowledgeMode()
JmsActorConfig
configuredAcknowledgeMode
in interface JmsActorConfig
public AdaptrisMessageListener configuredMessageListener()
JmsActorConfig
configuredMessageListener
in interface JmsActorConfig
public javax.jms.Session currentSession()
JmsActorConfig
currentSession
in interface JmsActorConfig
public org.slf4j.Logger currentLogger()
JmsActorConfig
currentLogger
in interface JmsActorConfig
public java.lang.String configuredClientId()
JmsConnectionConfig
configuredClientId
in interface JmsConnectionConfig
public java.lang.String configuredPassword()
JmsConnectionConfig
configuredPassword
in interface JmsConnectionConfig
public java.lang.String configuredUserName()
JmsConnectionConfig
configuredUserName
in interface JmsConnectionConfig
public VendorImplementation configuredVendorImplementation()
JmsConnectionConfig
configuredVendorImplementation
in interface JmsConnectionConfig
public java.lang.Boolean getAdditionalDebug()
public boolean additionalDebug()
public void setAdditionalDebug(java.lang.Boolean b)
b
- the additionalDebug to setpublic long rollbackTimeout()
JmsActorConfig
rollbackTimeout
in interface JmsActorConfig
public void setManagedTransaction(boolean managedTransaction)
public boolean isManagedTransaction()
isManagedTransaction
in interface JmsActorConfig
public java.lang.String consumeLocationKey()
MessageTypeTranslatorImp.getMoveJmsHeaders()
is true.consumeLocationKey
in interface AdaptrisMessageConsumer