Package com.adaptris.core.jms
Class JmsPollingConsumerImpl
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.AdaptrisPollingConsumer
-
- com.adaptris.core.jms.BaseJmsPollingConsumerImpl
-
- com.adaptris.core.jms.JmsPollingConsumerImpl
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,JmsActorConfig
,JmsConnectionConfig
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
JmsPollingConsumer
,PasPollingConsumer
,PtpPollingConsumer
public abstract class JmsPollingConsumerImpl extends BaseJmsPollingConsumerImpl implements JmsConnectionConfig
Abstract implementation ofAdaptrisPollingConsumer
for queues and topics.The behaviour of this consumer differs from the standard
JmsConsumerImpl
concrete implementations. This consumer has the following steps.- Connects to broker.
- Attempts to obtain a
Message
within the givenBaseJmsPollingConsumerImpl.getReceiveTimeout()
. - If successful, processes the
javax.jms.Message
and repeats until no more messages. - Closes the connection.
If connection attempt fails, the poller sleeps for the configured interval then tries again.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.AdaptrisPollingConsumer
AdaptrisPollingConsumer.LockOperator
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description JmsPollingConsumerImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
additionalDebug()
void
close()
Closes the component.java.lang.String
configuredClientId()
The client id.protected abstract java.lang.String
configuredEndpoint()
java.lang.String
configuredPassword()
The password.java.lang.String
configuredUserName()
The username.VendorImplementation
configuredVendorImplementation()
The vendor specific implementation.protected javax.jms.ConnectionFactory
createConnectionFactory()
protected abstract javax.jms.MessageConsumer
createConsumer()
protected javax.jms.Session
createSession(int acknowledgeMode, boolean transacted)
org.slf4j.Logger
currentLogger()
Return the configured logger.java.lang.Boolean
getAdditionalDebug()
Set additional trace debug logsjava.lang.String
getClientId()
java.lang.String
getPassword()
java.lang.String
getUserName()
@NonNull VendorImplementation
getVendorImplementation()
protected java.lang.String
newThreadName()
protected void
prepareConsumer()
protected int
processMessages()
Implemented by protocol-specific sub-classes.void
setAdditionalDebug(java.lang.Boolean additionalDebug)
Set additional trace debug logsvoid
setClientId(java.lang.String s)
Sets the optional JMS client ID.void
setPassword(java.lang.String s)
Sets the password for the specified user.void
setUserName(java.lang.String s)
void
setVendorImplementation(@NonNull VendorImplementation vendorImplementation)
-
Methods inherited from class com.adaptris.core.jms.BaseJmsPollingConsumerImpl
closeMessageConsumer, closeSession, configuredAcknowledgeMode, configuredCorrelationIdSource, configuredMessageListener, configuredMessageTranslator, consumeLocationKey, currentSession, doProcessMessage, getAcknowledgeMode, getCorrelationIdSource, getMessageSelector, getMessageTranslator, getReceiveTimeout, init, initConsumer, initSession, isManagedTransaction, messageConsumer, messageHandler, rollbackTimeout, setAcknowledgeMode, setCorrelationIdSource, setManagedTransaction, setMessageSelector, setMessageTranslator, setReceiveTimeout
-
Methods inherited from class com.adaptris.core.AdaptrisPollingConsumer
continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, 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.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
prepareConsumer
protected void prepareConsumer() throws CoreException
- Specified by:
prepareConsumer
in classAdaptrisPollingConsumer
- Throws:
CoreException
-
newThreadName
protected java.lang.String newThreadName()
- Overrides:
newThreadName
in classAdaptrisMessageConsumerImp
-
configuredEndpoint
protected abstract java.lang.String configuredEndpoint()
-
createConnectionFactory
protected javax.jms.ConnectionFactory createConnectionFactory() throws java.lang.Exception
- Throws:
java.lang.Exception
-
createSession
protected javax.jms.Session createSession(int acknowledgeMode, boolean transacted) throws javax.jms.JMSException
- Specified by:
createSession
in classBaseJmsPollingConsumerImpl
- Throws:
javax.jms.JMSException
-
createConsumer
protected abstract javax.jms.MessageConsumer createConsumer() throws javax.jms.JMSException
- Specified by:
createConsumer
in classBaseJmsPollingConsumerImpl
- Throws:
javax.jms.JMSException
-
processMessages
protected int processMessages()
Description copied from class:AdaptrisPollingConsumer
Implemented by protocol-specific sub-classes.
- Specified by:
processMessages
in classAdaptrisPollingConsumer
-
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- Specified by:
close
in interfaceComponentLifecycle
- Overrides:
close
in classBaseJmsPollingConsumerImpl
- See Also:
ComponentLifecycle.close()
-
getClientId
public java.lang.String getClientId()
-
setClientId
public void setClientId(java.lang.String s)
Sets the optional JMS client ID. May not be empty, null means don't use client ID.
- Parameters:
s
- the optional JMS client ID, defaults to null.
-
getPassword
public java.lang.String getPassword()
-
setPassword
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
- Parameters:
s
- the password for the specified user
-
getUserName
public java.lang.String getUserName()
-
setUserName
public void setUserName(java.lang.String s)
-
currentLogger
public org.slf4j.Logger currentLogger()
Description copied from interface:JmsActorConfig
Return the configured logger.- Specified by:
currentLogger
in interfaceJmsActorConfig
- Returns:
- the logger.
-
configuredClientId
public java.lang.String configuredClientId()
Description copied from interface:JmsConnectionConfig
The client id.- Specified by:
configuredClientId
in interfaceJmsConnectionConfig
- Returns:
- the client id
-
configuredPassword
public java.lang.String configuredPassword()
Description copied from interface:JmsConnectionConfig
The password.- Specified by:
configuredPassword
in interfaceJmsConnectionConfig
- Returns:
- the password
-
configuredUserName
public java.lang.String configuredUserName()
Description copied from interface:JmsConnectionConfig
The username.- Specified by:
configuredUserName
in interfaceJmsConnectionConfig
- Returns:
- the username
-
configuredVendorImplementation
public VendorImplementation configuredVendorImplementation()
Description copied from interface:JmsConnectionConfig
The vendor specific implementation.- Specified by:
configuredVendorImplementation
in interfaceJmsConnectionConfig
- Returns:
- the vendor specific implementation
-
additionalDebug
public boolean additionalDebug()
-
getVendorImplementation
@NonNull public @NonNull VendorImplementation getVendorImplementation()
-
setVendorImplementation
public void setVendorImplementation(@NonNull @NonNull VendorImplementation vendorImplementation)
-
getAdditionalDebug
public java.lang.Boolean getAdditionalDebug()
Set additional trace debug logs
-
setAdditionalDebug
public void setAdditionalDebug(java.lang.Boolean additionalDebug)
Set additional trace debug logs
-
-