public class PullingJmsListener extends JmsListenerBase implements IPostboxListener<javax.jms.Message>, ICorrelatedPullingListener<javax.jms.Message>, HasSender, RunStateEnquiring
Listener
-class.
transacted
attribute. If this is set to true
, received messages are
committed or rolled back, possibly together with other actions, by the receiver or the pipeline.
In case of a failure, all actions within the transaction are rolled back.
Using jmsTransacted and acknowledgement
If jmsTransacted is set true
: 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 set true
! 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, transacted
should be used instead of listener.transacted
.
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 for listener.transacted
as well as for
listener.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)
specified Sender
, that in turn sends the message to
whatever it is configured to.
Notice: the JmsListener is ONLY capable of processing
javax.jms.TextMessage
s
JMSFacade.AcknowledgeMode, JMSFacade.DeliveryMode, JMSFacade.DestinationType, JMSFacade.SubscriberType
messagingSource
Constructor and Description |
---|
PullingJmsListener() |
Modifier and Type | Method and Description |
---|---|
void |
afterMessageProcessed(PipeLineResult plr,
RawMessageWrapper<javax.jms.Message> rawMessageWrapper,
PipeLineSession pipeLineSession)
Called to perform actions (like committing or sending a reply) after a message has been processed by the
Pipeline.
|
protected boolean |
canGoOn() |
void |
closeThread(Map<String,Object> threadContext)
Finalizes a message receiving thread.
|
RawMessageWrapper<javax.jms.Message> |
getRawMessage(Map<String,Object> threadContext)
Retrieves messages from queue or other channel, but does no processing on it.
|
RawMessageWrapper<javax.jms.Message> |
getRawMessage(String correlationId,
Map<String,Object> threadContext)
Retrieves messages from queue or other channel, but retrieves only
messages with the specified correlationId.
|
protected javax.jms.MessageConsumer |
getReceiver(Map<String,Object> threadContext,
javax.jms.Session session,
String correlationId) |
protected javax.jms.Session |
getSession(Map<String,Object> threadContext) |
Map<String,Object> |
openThread()
Prepares a thread for receiving messages.
|
protected void |
releaseReceiver(javax.jms.MessageConsumer receiver,
String correlationId) |
protected void |
releaseSession(javax.jms.Session session) |
RawMessageWrapper<javax.jms.Message> |
retrieveRawMessage(String messageSelector,
Map<String,Object> threadContext)
Retrieves the first message found from queue or other channel, that matches the
specified
messageSelector . |
protected void |
sendReply(PipeLineResult plr,
javax.jms.Destination replyTo,
String replyCid,
long timeToLive,
boolean ignoreInvalidDestinationException,
Map<String,Object> threadContext,
Map<String,Object> properties) |
void |
SetRunStateEnquirer(RunStateEnquirer enquirer) |
addParameter, close, configure, extractMessage, extractMessageProperties, getMessageProperties, getParameterList, messageWillBeRedeliveredOnExitStateError, open, prepareReply, prepareReply, setForceMessageIdAsCorrelationId, setReplyDeliveryMode, setReplyDestinationName, setReplyEncodingStyleURI, setReplyMessageTimeToLive, setReplyMessageType, setReplyNamespaceURI, setReplyPriority, setReplySoapAction, setSender, setSoap, setSoapHeaderSessionKey, setTimeout, setTimeOut, setUseReplyTo
checkTransactionManagerValidity, closeSession, createMessage, createSession, extractMessage, extractMessageBody, getAcknowledgeModeEnum, getConnectionFactoryInfo, getConnectionFactoryName, getContext, getDestination, getDestination, getJmsMessagingSource, getLogPrefix, getManagedConnectionFactory, getMessageConsumer, getMessageConsumer, getMessageConsumerForCorrelationId, getMessageProducer, getMessagingSource, getMessagingSourceFactory, getPhysicalDestinationName, getPhysicalDestinationShortName, getPhysicalDestinationShortName, isSessionsArePooled, logMessageDetails, send, send, send, send, send, send, send, sendByQueue, sendByTopic, setAckMode, setAcknowledgeMode, setAuthAlias, setCorrelationIdMaxLength, setCorrelationIdToHex, setCorrelationIdToHexPrefix, setDestinationName, setDestinationType, setJmsTransacted, setLookupDestination, setMessageCorrelationID, setMessageSelector, setMessageTimeToLive, setPersistent, setQueueConnectionFactoryName, setSubscriberType, setTopicConnectionFactoryName, setTransacted, toString, useJms102
getContext, getJndiEnv, setAuthentication, setCredentials, setInitialContextFactoryName, setJmsRealm, setJndiAuthAlias, setJndiContextPrefix, setJndiProperties, setName, setPrincipal, setProviderURL, setSecurityProtocol, setUrlPkgPrefixes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, configure, extractMessage, open
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getDomain
isTransacted
protected javax.jms.Session getSession(Map<String,Object> threadContext) throws ListenerException
ListenerException
protected void releaseSession(javax.jms.Session session) throws ListenerException
ListenerException
protected javax.jms.MessageConsumer getReceiver(Map<String,Object> threadContext, javax.jms.Session session, String correlationId) throws ListenerException
ListenerException
protected void releaseReceiver(javax.jms.MessageConsumer receiver, String correlationId) throws ListenerException
ListenerException
@Nonnull public Map<String,Object> openThread() throws ListenerException
IPullingListener
openThread
in interface IPullingListener<javax.jms.Message>
null
, must be a mutable map type.ListenerException
public void closeThread(@Nonnull Map<String,Object> threadContext) throws ListenerException
IPullingListener
IListener.close()
is called.closeThread
in interface IPullingListener<javax.jms.Message>
ListenerException
public void afterMessageProcessed(PipeLineResult plr, RawMessageWrapper<javax.jms.Message> rawMessageWrapper, PipeLineSession pipeLineSession) throws ListenerException
IListener
afterMessageProcessed
in interface IListener<javax.jms.Message>
afterMessageProcessed
in class JmsListenerBase
ListenerException
protected void sendReply(PipeLineResult plr, javax.jms.Destination replyTo, String replyCid, long timeToLive, boolean ignoreInvalidDestinationException, Map<String,Object> threadContext, Map<String,Object> properties) throws SenderException, ListenerException, NamingException, javax.jms.JMSException, IOException
sendReply
in class JmsListenerBase
SenderException
ListenerException
NamingException
javax.jms.JMSException
IOException
public RawMessageWrapper<javax.jms.Message> getRawMessage(@Nonnull Map<String,Object> threadContext) throws ListenerException
getRawMessage
in interface IPullingListener<javax.jms.Message>
ListenerException
public RawMessageWrapper<javax.jms.Message> getRawMessage(String correlationId, Map<String,Object> threadContext) throws ListenerException, TimeoutException
ICorrelatedPullingListener
getRawMessage
in interface ICorrelatedPullingListener<javax.jms.Message>
ListenerException
TimeoutException
public RawMessageWrapper<javax.jms.Message> retrieveRawMessage(String messageSelector, Map<String,Object> threadContext) throws ListenerException
IPostboxListener
messageSelector
.
retrieveRawMessage
in interface IPostboxListener<javax.jms.Message>
messageSelector
- search criteria for messages. Not that the format of the selector
changes per listener, for example a JMSListener's messageSelector follows the JMS specification.threadContext
- context in which the method is calledListenerException
IPostboxListener.retrieveRawMessage(String, Map)
protected boolean canGoOn()
public void SetRunStateEnquirer(RunStateEnquirer enquirer)
SetRunStateEnquirer
in interface RunStateEnquiring
Copyright © 2023 Frank!Framework. All rights reserved.