Class PushingJmsListener
- java.lang.Object
-
- nl.nn.adapterframework.jndi.JndiBase
-
- nl.nn.adapterframework.jms.JMSFacade
-
- nl.nn.adapterframework.jms.JmsListenerBase
-
- nl.nn.adapterframework.jms.PushingJmsListener
-
- All Implemented Interfaces:
HasPhysicalDestination
,HasSender
,IConfigurable
,IConfigurationAware
,IKnowsDeliveryCount<javax.jms.Message>
,IListener<javax.jms.Message>
,INamedObject
,IPortConnectedListener<javax.jms.Message>
,IPushingListener<javax.jms.Message>
,IRedeliveringListener<javax.jms.Message>
,IScopeProvider
,IThreadCountControllable
,IWithParameters
,IXAEnabled
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
JmsListener
public class PushingJmsListener extends JmsListenerBase implements IPortConnectedListener<javax.jms.Message>, IThreadCountControllable, IKnowsDeliveryCount<javax.jms.Message>
JMSListener re-implemented as a pushing listener rather than a pulling listener. The JMS messages have to come in from an external source: an MDB or a Spring message container. This version of theJmsListener
supports distributed transactions using the XA-protocol. No special action is required to have the listener join the transaction.Using jmsTransacted and acknowledgement
If jmsTransacted is settrue
, it should ensure that a message is received and processed on a both or nothing basis. IBIS will commit the the message, otherwise perform rollback. However, using jmsTransacted, IBIS does not bring transactions within the adapters under transaction control, compromising the idea of atomic transactions. In the roll-back situation messages sent to other destinations within the Pipeline are NOT rolled back if jmsTransacted is settrue
! In the failure situation the message is therefore completely processed, and the roll back does not mean that the processing is rolled back! To obtain the correct (transactional) behaviour, settransacted
="true" for the enclosing Receiver. Do not use jmsTransacted for any new situation.Setting
listener.acknowledgeMode
to "auto" means that messages are allways acknowledged (removed from the queue, regardless of what the status of the Adapter is. "client" means that the message will only be removed from the queue when the state of the Adapter equals the success state. The "dups" mode instructs the session to lazily acknowledge the delivery of the messages. This is likely to result in the delivery of duplicate messages if JMS fails. It should be used by consumers who are tolerant in processing duplicate messages. In cases where the client is tolerant of duplicate messages, some enhancement in performance can be achieved using this mode, since a session has lower overhead in trying to prevent duplicate messages.The setting for
listener.acknowledgeMode
will only be processed if the setting forlistener.transacted
as well as forlistener.jmsTransacted
is false.If
useReplyTo
is set and a replyTo-destination is specified in the message, the JmsListener sends the result of the processing in the pipeline to this destination. Otherwise the result is sent using the (optionally) specifiedSender
, that in turn sends the message to whatever it is configured to.Notice: the JmsListener is ONLY capable of processing
TextMessage
s andBytesMessage
- Since:
- 4.8
- Author:
- Tim van der Leeuw
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class nl.nn.adapterframework.jms.JMSFacade
JMSFacade.AcknowledgeMode, JMSFacade.DeliveryMode, JMSFacade.DestinationType, JMSFacade.MessageClass, JMSFacade.SubscriberType
-
-
Field Summary
-
Fields inherited from class nl.nn.adapterframework.jms.JMSFacade
JMS_MESSAGECLASS_KEY, messagingSource
-
-
Constructor Summary
Constructors Constructor Description PushingJmsListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases references to serviceQueue and connection.void
configure()
configure()
is called once at startup of the framework in theconfigure()
method of the owner of this listener.void
decreaseThreadCount()
IListenerConnector.CacheMode
getCacheMode()
int
getCurrentThreadCount()
int
getDeliveryCount(RawMessageWrapper<javax.jms.Message> rawMessage)
IbisExceptionListener
getExceptionListener()
IMessageHandler<javax.jms.Message>
getHandler()
IListenerConnector<javax.jms.Message>
getJmsConnector()
IListenerConnector<javax.jms.Message>
getListenerPortConnector()
int
getMaxThreadCount()
long
getPollGuardInterval()
Receiver<javax.jms.Message>
getReceiver()
void
increaseThreadCount()
boolean
isThreadCountControllable()
boolean
isThreadCountReadable()
void
open()
Obtains a connection and a serviceQueue.void
setCacheMode(IListenerConnector.CacheMode cacheMode)
void
setDestinationName(String destinationName)
Name of the JMS destination (queue or topic) to usevoid
setExceptionListener(IbisExceptionListener exceptionListener)
Set a (single) listener that will be notified of any exceptions.void
setHandler(IMessageHandler<javax.jms.Message> handler)
Set the handler that will do the processing of the message.void
setJmsConnector(IListenerConnector<javax.jms.Message> jmsConnector)
void
setPollGuardInterval(long pollGuardInterval)
Interval in milliseconds for the poll guard to check whether a successful poll was done by the receive (https://docs.oracle.com/javaee/7/api/javax/jms/messageconsumer.html#receive-long-) since last check.void
setReceiver(Receiver<javax.jms.Message> receiver)
RawMessageWrapper<javax.jms.Message>
wrapRawMessage(javax.jms.Message rawMessage, PipeLineSession session)
Wrap a raw message in a MessageWrapper.-
Methods inherited from class nl.nn.adapterframework.jms.JmsListenerBase
addParameter, afterMessageProcessed, extractMessage, extractMessageProperties, getForceMessageIdAsCorrelationId, getMessageProperties, getParameterList, getReplyDeliveryMode, getReplyDestinationName, getReplyEncodingStyleURI, getReplyMessageTimeToLive, getReplyMessageType, getReplyNamespaceURI, getReplyPriority, getReplySoapAction, getSender, getSoapHeaderSessionKey, getTimeOut, isSoap, isUseReplyTo, messageWillBeRedeliveredOnExitStateError, prepareReply, prepareReply, sendReply, setForceMessageIdAsCorrelationId, setReplyDeliveryMode, setReplyDestinationName, setReplyEncodingStyleURI, setReplyMessageTimeToLive, setReplyMessageType, setReplyNamespaceURI, setReplyPriority, setReplySoapAction, setSender, setSoap, setSoapHeaderSessionKey, setTimeout, setTimeOut, setUseReplyTo
-
Methods inherited from class nl.nn.adapterframework.jms.JMSFacade
checkTransactionManagerValidity, closeSession, createBytesMessage, createMessage, createMessage, createSession, createTextMessage, extractMessage, extractMessageBody, getAcknowledgeModeEnum, getAuthAlias, getConnectionFactoryFactory, getConnectionFactoryInfo, getConnectionFactoryName, getContext, getCorrelationIdMaxLength, getCorrelationIdToHexPrefix, getDestination, getDestination, getDestinationName, getDestinationType, getDomain, getJmsMessagingSource, getLogPrefix, getManagedConnectionFactory, getMessageClass, getMessageConsumer, getMessageConsumer, getMessageConsumerForCorrelationId, getMessageProducer, getMessageSelector, getMessageTimeToLive, getMessagingSource, getMessagingSourceFactory, getPhysicalDestinationName, getPhysicalDestinationShortName, getPhysicalDestinationShortName, getProxiedDestinationNames, getQueueConnectionFactoryName, getSubscriberType, getTopicConnectionFactoryName, getTxManager, isCorrelationIdToHex, isJmsTransacted, isLookupDestination, isPersistent, isSessionsArePooled, isTransacted, isUseTopicFunctions, logMessageDetails, send, send, send, send, send, send, send, sendByQueue, sendByTopic, setAckMode, setAcknowledgeMode, setAuthAlias, setConnectionFactoryFactory, setCorrelationIdMaxLength, setCorrelationIdToHex, setCorrelationIdToHexPrefix, setDestinationType, setJmsTransacted, setLookupDestination, setMessageClass, setMessageCorrelationID, setMessageSelector, setMessageTimeToLive, setPersistent, setProxiedDestinationNames, setQueueConnectionFactoryName, setSubscriberType, setTopicConnectionFactoryName, setTransacted, setTxManager, toString, useJms102
-
Methods inherited from class nl.nn.adapterframework.jndi.JndiBase
getApplicationContext, getAuthentication, getConfigurationClassLoader, getContext, getCredentials, getInitialContextFactoryName, getJmsRealmName, getJndiAuthAlias, getJndiContextPrefix, getJndiEnv, getJndiProperties, getName, getPrincipal, getProviderURL, getSecurityProtocol, getUrlPkgPrefixes, setApplicationContext, setAuthentication, setCredentials, setInitialContextFactoryName, setJmsRealm, setJndiAuthAlias, setJndiContextPrefix, setJndiProperties, setName, setPrincipal, setProviderURL, setSecurityProtocol, setUrlPkgPrefixes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
-
Methods inherited from interface nl.nn.adapterframework.core.IConfigurationAware
getApplicationContext, getName
-
Methods inherited from interface nl.nn.adapterframework.core.IListener
afterMessageProcessed, extractMessage
-
Methods inherited from interface nl.nn.adapterframework.core.INamedObject
getName, setName
-
Methods inherited from interface nl.nn.adapterframework.core.IPortConnectedListener
checkTransactionManagerValidity
-
Methods inherited from interface nl.nn.adapterframework.core.IScopeProvider
getConfigurationClassLoader
-
-
-
-
Method Detail
-
configure
public void configure() throws ConfigurationException
Description copied from interface:IListener
configure()
is called once at startup of the framework in theconfigure()
method of the owner of this listener. Purpose of this method is to reduce creating connections to databases etc. in theIPullingListener.getRawMessage(Map)
method. As much as possible class-instantiating should take place in theconfigure()
oropen()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIListener<javax.jms.Message>
- Overrides:
configure
in classJmsListenerBase
- Throws:
ConfigurationException
-
open
public void open() throws ListenerException
Description copied from class:JMSFacade
Obtains a connection and a serviceQueue.- Specified by:
open
in interfaceIListener<javax.jms.Message>
- Overrides:
open
in classJmsListenerBase
- Throws:
ListenerException
-
close
public void close()
Description copied from class:JMSFacade
Releases references to serviceQueue and connection.- Specified by:
close
in interfaceIListener<javax.jms.Message>
- Overrides:
close
in classJmsListenerBase
-
getListenerPortConnector
public IListenerConnector<javax.jms.Message> getListenerPortConnector()
- Specified by:
getListenerPortConnector
in interfaceIPortConnectedListener<javax.jms.Message>
-
wrapRawMessage
public RawMessageWrapper<javax.jms.Message> wrapRawMessage(javax.jms.Message rawMessage, PipeLineSession session) throws ListenerException
Description copied from interface:IPushingListener
Wrap a raw message in a MessageWrapper. PopulatePipeLineSession
with properties from the message.- Specified by:
wrapRawMessage
in interfaceIPushingListener<javax.jms.Message>
- Parameters:
rawMessage
- The raw message data, unwrappedsession
-PipeLineSession
to populate with properties from the message.- Returns:
- Wrapped raw message
- Throws:
ListenerException
- If any exception occurs during wrapping, aListenerException
is thrown.
-
isThreadCountReadable
public boolean isThreadCountReadable()
- Specified by:
isThreadCountReadable
in interfaceIThreadCountControllable
-
isThreadCountControllable
public boolean isThreadCountControllable()
- Specified by:
isThreadCountControllable
in interfaceIThreadCountControllable
-
getCurrentThreadCount
public int getCurrentThreadCount()
- Specified by:
getCurrentThreadCount
in interfaceIThreadCountControllable
-
getMaxThreadCount
public int getMaxThreadCount()
- Specified by:
getMaxThreadCount
in interfaceIThreadCountControllable
-
increaseThreadCount
public void increaseThreadCount()
- Specified by:
increaseThreadCount
in interfaceIThreadCountControllable
-
decreaseThreadCount
public void decreaseThreadCount()
- Specified by:
decreaseThreadCount
in interfaceIThreadCountControllable
-
getDeliveryCount
public int getDeliveryCount(RawMessageWrapper<javax.jms.Message> rawMessage)
- Specified by:
getDeliveryCount
in interfaceIKnowsDeliveryCount<javax.jms.Message>
-
setDestinationName
@Mandatory public void setDestinationName(String destinationName)
Description copied from class:JMSFacade
Name of the JMS destination (queue or topic) to use- Overrides:
setDestinationName
in classJMSFacade
-
setCacheMode
public void setCacheMode(IListenerConnector.CacheMode cacheMode)
-
setPollGuardInterval
public void setPollGuardInterval(long pollGuardInterval)
Interval in milliseconds for the poll guard to check whether a successful poll was done by the receive (https://docs.oracle.com/javaee/7/api/javax/jms/messageconsumer.html#receive-long-) since last check. If polling has stopped this will be logged and the listener will be stopped and started in an attempt to workaround problems with polling. Polling might stop due to bugs in the JMS driver/implementation which should be fixed by the supplier. As the poll time includes reading and processing of the message no successful poll might be registered since the last check when message processing takes a long time, hence while messages are being processed the check on last successful poll will be skipped. Set to -1 to disable.- Default value
- ten times the specified timeout
-
getCacheMode
public IListenerConnector.CacheMode getCacheMode()
-
getPollGuardInterval
public long getPollGuardInterval()
-
getJmsConnector
public IListenerConnector<javax.jms.Message> getJmsConnector()
-
setJmsConnector
public void setJmsConnector(IListenerConnector<javax.jms.Message> jmsConnector)
-
getHandler
public IMessageHandler<javax.jms.Message> getHandler()
- Specified by:
getHandler
in interfaceIPortConnectedListener<javax.jms.Message>
-
setHandler
public void setHandler(IMessageHandler<javax.jms.Message> handler)
Description copied from interface:IPushingListener
Set the handler that will do the processing of the message. Each of the received messages must be pushed through handler.processMessage()- Specified by:
setHandler
in interfaceIPushingListener<javax.jms.Message>
-
getReceiver
public Receiver<javax.jms.Message> getReceiver()
- Specified by:
getReceiver
in interfaceIPortConnectedListener<javax.jms.Message>
-
setReceiver
public void setReceiver(Receiver<javax.jms.Message> receiver)
- Specified by:
setReceiver
in interfaceIPortConnectedListener<javax.jms.Message>
-
getExceptionListener
public IbisExceptionListener getExceptionListener()
- Specified by:
getExceptionListener
in interfaceIPortConnectedListener<javax.jms.Message>
-
setExceptionListener
public void setExceptionListener(IbisExceptionListener exceptionListener)
Description copied from interface:IPushingListener
Set a (single) listener that will be notified of any exceptions. The listener should use this listener to notify the receiver of any exception that occurs outside the processing of a message.- Specified by:
setExceptionListener
in interfaceIPushingListener<javax.jms.Message>
-
-