Class JmsSyncConsumer
- java.lang.Object
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,JmsActorConfig
,MessageEventGenerator
,StateManagedComponent
@ComponentProfile(summary="Pickup messages from a JMS broker (queue or topic) by actively polling it", tag="consumer,jms", recommended=JmsConnection.class) public class JmsSyncConsumer extends BaseJmsPollingConsumerImpl
JMS synchronous consumer implementation that can target queues or topics via an RFC6167 style endpoint.For instance
jms:queue:myQueueName
will consume from a queue calledmyQueueName
andjms:topic:myTopicName
from a topic calledmyTopicName
While RFC6167 defines the ability to use jndi to lookup the (as part of the 'jndi' variant section); this is not supported. There is also support for
subscriptionId
which indicates the subscriptionId that should be used when attaching a subscriber to a topic;jms:topic:MyTopicName?subscriptionId=myId
would return aJmsDestination.subscriptionId()
ofmyId
. If a subscription ID is not specified, then a durable subscriber is never created; specifying a subscription ID automatically means a durable subscriber.Also supported is the JMS 2.0 sharedConsumerId, should you wish to create a multiple load balancing consumers on a single topic endpoint;
For instance you could have the following destinations:jms:topic:MyTopicName?sharedConsumerId=12345
- jms:queue:MyQueueName
- jms:topic:MyTopicName
- jms:topic:MyTopicName?subscriptionId=mySubscriptionId
- jms:topic:MyTopicName?sharedConsumerId=mySharedConsumerId
- jms:topic:MyTopicName?subscriptionId=mySubscriptionId&sharedConsumerId=mySharedConsumerId
In the adapter configuration file this class is aliased as jms-poller which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
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 JmsSyncConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.jms.MessageConsumer
createConsumer()
protected javax.jms.Session
createSession(int acknowledgeMode, boolean transacted)
org.slf4j.Logger
currentLogger()
Return the configured logger.protected java.lang.Boolean
deferConsumerCreationToVendor()
protected java.lang.String
endpoint()
java.lang.Boolean
getDeferConsumerCreationToVendor()
Set to true if you wish to let the JMS message consumer be delegated by the configured vendor implementation.@NonNull java.lang.String
getEndpoint()
The RFC6167 format topic/queue.void
init()
Initialises the component.protected java.lang.String
messageSelector()
protected java.lang.String
newThreadName()
protected void
prepareConsumer()
protected int
processMessages()
Implemented by protocol-specific sub-classes.void
setDeferConsumerCreationToVendor(java.lang.Boolean deferConsumerCreationToVendor)
Set to true if you wish to let the JMS message consumer be delegated by the configured vendor implementation.void
setEndpoint(@NonNull java.lang.String endpoint)
The RFC6167 format topic/queue.JmsSyncConsumer
withEndpoint(java.lang.String s)
-
Methods inherited from class com.adaptris.core.jms.BaseJmsPollingConsumerImpl
close, closeMessageConsumer, closeSession, configuredAcknowledgeMode, configuredCorrelationIdSource, configuredMessageListener, configuredMessageTranslator, consumeLocationKey, currentSession, doProcessMessage, getAcknowledgeMode, getCorrelationIdSource, getMessageSelector, getMessageTranslator, getReceiveTimeout, 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
-
withEndpoint
public JmsSyncConsumer withEndpoint(java.lang.String s)
-
currentLogger
public org.slf4j.Logger currentLogger()
Description copied from interface:JmsActorConfig
Return the configured logger.- Returns:
- the logger.
-
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
- Overrides:
init
in classBaseJmsPollingConsumerImpl
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.init()
-
createConsumer
protected 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
-
prepareConsumer
protected void prepareConsumer() throws CoreException
- Specified by:
prepareConsumer
in classAdaptrisPollingConsumer
- Throws:
CoreException
-
messageSelector
protected java.lang.String messageSelector()
-
endpoint
protected java.lang.String endpoint()
-
newThreadName
protected java.lang.String newThreadName()
- Overrides:
newThreadName
in classAdaptrisMessageConsumerImp
-
createSession
protected javax.jms.Session createSession(int acknowledgeMode, boolean transacted) throws javax.jms.JMSException
- Specified by:
createSession
in classBaseJmsPollingConsumerImpl
- Throws:
javax.jms.JMSException
-
deferConsumerCreationToVendor
protected java.lang.Boolean deferConsumerCreationToVendor()
-
getDeferConsumerCreationToVendor
public java.lang.Boolean getDeferConsumerCreationToVendor()
Set to true if you wish to let the JMS message consumer be delegated by the configured vendor implementation.The default is false such that we use standard JMS 1.1/2.0 methods to create the appropriate consumers.
-
setDeferConsumerCreationToVendor
public void setDeferConsumerCreationToVendor(java.lang.Boolean deferConsumerCreationToVendor)
Set to true if you wish to let the JMS message consumer be delegated by the configured vendor implementation.The default is false such that we use standard JMS 1.1/2.0 methods to create the appropriate consumers.
-
getEndpoint
@NonNull public @NonNull java.lang.String getEndpoint()
The RFC6167 format topic/queue.
-
setEndpoint
public void setEndpoint(@NonNull @NonNull java.lang.String endpoint)
The RFC6167 format topic/queue.
-
-