Class JmsConsumerImpl
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.jms.JmsConsumerImpl
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,JmsActorConfig
,MessageEventGenerator
,StateManagedComponent
,javax.jms.MessageListener
- Direct Known Subclasses:
JmsConsumer
,PasConsumer
,PtpConsumer
public abstract class JmsConsumerImpl extends AdaptrisMessageConsumerImp implements javax.jms.MessageListener, JmsActorConfig
Contains behaviour common to PTP and PAS JMS message consumers.
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.jms.MessageConsumer
consumer
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description JmsConsumerImpl()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.int
configuredAcknowledgeMode()
Return the current acknowledge mode.CorrelationIdSource
configuredCorrelationIdSource()
Return the current correlation id source.protected abstract java.lang.String
configuredEndpoint()
AdaptrisMessageListener
configuredMessageListener()
return the current configured MessageListener.MessageTypeTranslator
configuredMessageTranslator()
Return the currently configured messageTranslator.java.lang.String
consumeLocationKey()
Provides the metadata key "JMSDestination" which will only be populated ifMessageTypeTranslatorImp.getMoveJmsHeaders()
is true.protected abstract javax.jms.MessageConsumer
createConsumer()
org.slf4j.Logger
currentLogger()
Return the configured logger.javax.jms.Session
currentSession()
Return the current jms session.java.lang.String
getAcknowledgeMode()
Returns the JMS acknowledge mode to use.CorrelationIdSource
getCorrelationIdSource()
Returns correlationIdSource.java.lang.String
getMessageSelector()
The message selector to use when matching messages to consumeMessageTypeTranslator
getMessageTranslator()
Returns the MessageTypeTranslator to use.void
init()
Initialises the component.boolean
isManagedTransaction()
protected java.lang.String
newThreadName()
void
onMessage(javax.jms.Message msg)
Called by the JMSSession
to deliver messages.void
prepare()
Prepare for initialisation.long
rollbackTimeout()
How long we should wait after a rollback before continuing on with processingvoid
setAcknowledgeMode(java.lang.String i)
Sets the JMS acknowledge mode to use.void
setCorrelationIdSource(CorrelationIdSource c)
Sets correlationIdSource.void
setManagedTransaction(boolean managedTransaction)
void
setMessageSelector(java.lang.String messageSelector)
The message selector to use when matching messages to consumevoid
setMessageTranslator(MessageTypeTranslator translator)
Sets the MessageTypeTranslator to use.void
start()
Starts the component.void
stop()
Stop the component-
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
-
onMessage
public void onMessage(javax.jms.Message msg)
Called by the JMS
Session
to deliver messages.- Specified by:
onMessage
in interfacejavax.jms.MessageListener
- Parameters:
msg
- ajavax.jms.Message
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
newThreadName
protected java.lang.String newThreadName()
- Overrides:
newThreadName
in classAdaptrisMessageConsumerImp
-
configuredEndpoint
protected abstract java.lang.String configuredEndpoint()
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.init()
-
createConsumer
protected abstract javax.jms.MessageConsumer createConsumer() throws javax.jms.JMSException, CoreException
- Throws:
javax.jms.JMSException
CoreException
-
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- Specified by:
stop
in interfaceComponentLifecycle
-
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.- Specified by:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
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
-
rollbackTimeout
public long rollbackTimeout()
Description copied from interface:JmsActorConfig
How long we should wait after a rollback before continuing on with processing- Specified by:
rollbackTimeout
in interfaceJmsActorConfig
- Returns:
- the timeout in ms.
-
setMessageTranslator
public void setMessageTranslator(MessageTypeTranslator translator)
Sets the MessageTypeTranslator to use.
- Parameters:
translator
- the MessageTypeTranslator to use
-
getMessageTranslator
public MessageTypeTranslator getMessageTranslator()
Returns the MessageTypeTranslator to use.
- Returns:
- the MessageTypeTranslator to use
-
setAcknowledgeMode
public void setAcknowledgeMode(java.lang.String i)
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
- Parameters:
i
- the JMS acknowledge mode to use
-
getAcknowledgeMode
public java.lang.String getAcknowledgeMode()
Returns the JMS acknowledge mode to use.
- Returns:
- the JMS acknowledge mode to use
-
getCorrelationIdSource
public CorrelationIdSource getCorrelationIdSource()
Returns correlationIdSource.
- Returns:
- correlationIdSource
-
setCorrelationIdSource
public void setCorrelationIdSource(CorrelationIdSource c)
Sets correlationIdSource.
- Parameters:
c
- the correlationIdSource to set
-
configuredCorrelationIdSource
public CorrelationIdSource configuredCorrelationIdSource()
Description copied from interface:JmsActorConfig
Return the current correlation id source.- Specified by:
configuredCorrelationIdSource
in interfaceJmsActorConfig
- Returns:
- the correlation id source
-
configuredMessageTranslator
public MessageTypeTranslator configuredMessageTranslator()
Description copied from interface:JmsActorConfig
Return the currently configured messageTranslator.- Specified by:
configuredMessageTranslator
in interfaceJmsActorConfig
- Returns:
- the MessageTypeTranslator instance.
-
configuredAcknowledgeMode
public int configuredAcknowledgeMode()
Description copied from interface:JmsActorConfig
Return the current acknowledge mode.- Specified by:
configuredAcknowledgeMode
in interfaceJmsActorConfig
- Returns:
- the session acknowledge mode.
-
configuredMessageListener
public AdaptrisMessageListener configuredMessageListener()
Description copied from interface:JmsActorConfig
return the current configured MessageListener.- Specified by:
configuredMessageListener
in interfaceJmsActorConfig
- Returns:
- the adaptris message listener instance.
-
currentSession
public javax.jms.Session currentSession()
Description copied from interface:JmsActorConfig
Return the current jms session.- Specified by:
currentSession
in interfaceJmsActorConfig
- Returns:
- the current javax.jms.Session
-
currentLogger
public org.slf4j.Logger currentLogger()
Description copied from interface:JmsActorConfig
Return the configured logger.- Specified by:
currentLogger
in interfaceJmsActorConfig
- Returns:
- the logger.
-
setManagedTransaction
public void setManagedTransaction(boolean managedTransaction)
-
isManagedTransaction
public boolean isManagedTransaction()
- Specified by:
isManagedTransaction
in interfaceJmsActorConfig
- Returns:
- whether we are in a managed (XA) transaction
-
consumeLocationKey
public java.lang.String consumeLocationKey()
Provides the metadata key "JMSDestination" which will only be populated ifMessageTypeTranslatorImp.getMoveJmsHeaders()
is true.- Specified by:
consumeLocationKey
in interfaceAdaptrisMessageConsumer
- Returns:
- the metadata key;
- Since:
- 3.9.0
-
getMessageSelector
public java.lang.String getMessageSelector()
The message selector to use when matching messages to consume
-
setMessageSelector
public void setMessageSelector(java.lang.String messageSelector)
The message selector to use when matching messages to consume
-
-