Package org.frankframework.jms
Class AbstractJmsListener
java.lang.Object
org.frankframework.jndi.JndiBase
org.frankframework.jms.JMSFacade
org.frankframework.jms.AbstractJmsListener
- All Implemented Interfaces:
HasPhysicalDestination
,HasSender
,IConfigurable
,IConfigurationAware
,IListener<jakarta.jms.Message>
,INamedObject
,IRedeliveringListener<jakarta.jms.Message>
,IScopeProvider
,IWithParameters
,IXAEnabled
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
PullingJmsListener
,PushingJmsListener
public abstract class AbstractJmsListener
extends JMSFacade
implements HasSender, IWithParameters, IRedeliveringListener<jakarta.jms.Message>
Common baseclass for Pulling and Pushing JMS Listeners.
- Since:
- 4.9
- Author:
- Gerrit van Brakel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.frankframework.jms.JMSFacade
JMSFacade.AcknowledgeMode, JMSFacade.DeliveryMode, JMSFacade.DestinationType, JMSFacade.MessageClass, JMSFacade.SubscriberType
-
Field Summary
Fields inherited from class org.frankframework.jms.JMSFacade
JMS_MESSAGECLASS_KEY, messagingSource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
afterMessageProcessed
(PipeLineResult plr, RawMessageWrapper<jakarta.jms.Message> rawMessageWrapper, PipeLineSession session) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.void
configure()
is called once at startup of the framework in theconfigure()
method of the owner of this listener.extractMessage
(RawMessageWrapper<jakarta.jms.Message> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)
.extractMessageProperties
(jakarta.jms.Message rawMessage) Fill in thread-context with things needed by the JMSListener code.getMessageProperties
(PipeLineSession session) Set additional message headers/properties on the JMS response, read after message has been processed!return the Parameterslong
int
long
boolean
isSoap()
boolean
boolean
prepareReply
(Message rawReply, Map<String, Object> threadContext) protected void
sendReply
(PipeLineResult plr, jakarta.jms.Destination replyTo, String replyCid, long timeToLive, boolean ignoreInvalidDestinationException, PipeLineSession pipeLineSession, Map<String, Object> properties) void
By default, the JmsListener takes the Correlation-ID (if present) as the ID that has to be used as Correlation-ID of the reply.void
setReplyDeliveryMode
(JMSFacade.DeliveryMode replyDeliveryMode) Controls mode that reply messages are sent withvoid
setReplyDestinationName
(String destinationName) Name of the JMS destination (queue or topic) to use for sending replies.void
setReplyEncodingStyleURI
(String string) void
setReplyMessageTimeToLive
(long l) Time in milliseconds after which the reply-message will expirevoid
setReplyMessageType
(String string) Value of the JMSType field of the reply messagevoid
setReplyNamespaceURI
(String string) void
setReplyPriority
(int i) Sets the priority that is used to deliver the reply message.void
setReplySoapAction
(String string) void
Deprecated, for removal: This API element is subject to removal in a future version.void
setSoap
(boolean b) Iftrue
, messages sent are put in a SOAP envelopevoid
setSoapHeaderSessionKey
(String string) sessionKey to store the SOAP header of the incoming messagevoid
setTimeout
(long newTimeout) Receive timeout in milliseconds as specified by the JMS API, see https://docs.oracle.com/javaee/7/api/javax/jms/MessageConsumer.html#receive-long-void
setUseReplyTo
(boolean newUseReplyTo) Flag if reply-to queue from the request message should be used or not.void
start()
Obtains a connection and a serviceQueue.void
stop()
Releases references to serviceQueue and connection.Methods inherited from class org.frankframework.jms.JMSFacade
checkTransactionManagerValidity, closeSession, createBytesMessage, createMessage, createMessage, createSession, createTextMessage, extractMessage, extractMessageBody, getAcknowledgeMode, getAuthAlias, getConnectionFactoryFactory, getConnectionFactoryInfo, getConnectionFactoryName, getContext, getCorrelationIdMaxLength, getCorrelationIdToHexPrefix, getDestination, getDestination, getDestinationName, getDestinationType, getDomain, getJmsMessagingSource, getLogPrefix, 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, setAcknowledgeMode, setAuthAlias, setConnectionFactoryFactory, setCorrelationIdMaxLength, setCorrelationIdToHex, setCorrelationIdToHexPrefix, setDestinationName, setDestinationType, setJmsTransacted, setLookupDestination, setMessageClass, setMessageCorrelationID, setMessageSelector, setMessageTimeToLive, setPersistent, setProxiedDestinationNames, setQueueConnectionFactoryName, setSubscriberType, setTopicConnectionFactoryName, setTransacted, setTxManager, toString
Methods inherited from class org.frankframework.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 org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
-
Constructor Details
-
AbstractJmsListener
public AbstractJmsListener()
-
-
Method Details
-
configure
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()
orIListener.start()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIListener<jakarta.jms.Message>
- Overrides:
configure
in classJMSFacade
- Throws:
ConfigurationException
-
start
public void start()Description copied from class:JMSFacade
Obtains a connection and a serviceQueue. -
stop
public void stop()Description copied from class:JMSFacade
Releases references to serviceQueue and connection. -
extractMessageProperties
Fill in thread-context with things needed by the JMSListener code. This includes a Session. The Session object can be passed in externally.- Parameters:
rawMessage
- - Original message received, can not benull
- Returns:
- A
Map
with the properties of the JMSMessage
.
-
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<jakarta.jms.Message> rawMessage, @Nonnull Map<String, Object> context) throws ListenerExceptionExtracts data from message obtained fromIPullingListener.getRawMessage(Map)
. May also extract other parameters from the message and put those in the context.- Specified by:
extractMessage
in interfaceIListener<jakarta.jms.Message>
- Parameters:
rawMessage
- TheRawMessageWrapper
from which to extract theMessage
.context
- Context to populate. Either aPipeLineSession
or athreadContext
depending on caller.- Returns:
- String input
Message
for adapter. - Throws:
ListenerException
-
prepareReply
public Message prepareReply(Message rawReply, Map<String, Object> threadContext) throws ListenerException- Throws:
ListenerException
-
prepareReply
public Message prepareReply(Message rawReply, Map<String, Object> threadContext, String soapHeader) throws ListenerException- Throws:
ListenerException
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult plr, RawMessageWrapper<jakarta.jms.Message> rawMessageWrapper, PipeLineSession session) throws ListenerException Description copied from interface:IListener
Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessed
in interfaceIListener<jakarta.jms.Message>
- Throws:
ListenerException
-
messageWillBeRedeliveredOnExitStateError
public boolean messageWillBeRedeliveredOnExitStateError()- Specified by:
messageWillBeRedeliveredOnExitStateError
in interfaceIRedeliveringListener<jakarta.jms.Message>
-
sendReply
protected void sendReply(PipeLineResult plr, jakarta.jms.Destination replyTo, String replyCid, long timeToLive, boolean ignoreInvalidDestinationException, PipeLineSession pipeLineSession, Map<String, Object> properties) throws ListenerException, jakarta.jms.JMSException, IOException, SenderException- Throws:
ListenerException
jakarta.jms.JMSException
IOException
SenderException
-
setSender
Deprecated, for removal: This API element is subject to removal in a future version. -
getMessageProperties
Set additional message headers/properties on the JMS response, read after message has been processed!- Parameters:
session
- which has been built during the pipeline- Returns:
- a map with headers to set to the JMS response, or
null
if there was no session or no parameters.
-
addParameter
- Specified by:
addParameter
in interfaceIWithParameters
-
getParameterList
return the Parameters- Specified by:
getParameterList
in interfaceIWithParameters
-
setForceMessageIdAsCorrelationId
By default, the JmsListener takes the Correlation-ID (if present) as the ID that has to be used as Correlation-ID of the reply. When set totrue
, the messageID is used as Correlation-ID of the reply.- Default value
- false
-
setTimeout
public void setTimeout(long newTimeout) Receive timeout in milliseconds as specified by the JMS API, see https://docs.oracle.com/javaee/7/api/javax/jms/MessageConsumer.html#receive-long-- Default value
- 1000
-
setUseReplyTo
public void setUseReplyTo(boolean newUseReplyTo) Flag if reply-to queue from the request message should be used or not.- Default value
- true
-
setReplyDestinationName
Name of the JMS destination (queue or topic) to use for sending replies. IfuseReplyTo=true
, the sender specified reply destination takes precedence over this one. -
setReplyMessageType
Value of the JMSType field of the reply message- Default value
- not set by application
-
setReplyDeliveryMode
Controls mode that reply messages are sent with- Default value
- NON_PERSISTENT
-
setReplyPriority
public void setReplyPriority(int i) Sets the priority that is used to deliver the reply message. Ranges from 0 to 9. Effectively the default priority is set by JMS to 4,-1
means not set and thus uses the JMS default- Default value
- -1
-
setReplyMessageTimeToLive
public void setReplyMessageTimeToLive(long l) Time in milliseconds after which the reply-message will expire- Default value
- 0
-
setSoap
public void setSoap(boolean b) Iftrue
, messages sent are put in a SOAP envelope- Default value
- false
-
setReplyEncodingStyleURI
-
setReplyNamespaceURI
-
setReplySoapAction
-
setSoapHeaderSessionKey
sessionKey to store the SOAP header of the incoming message- Default value
- soapHeader
-
getTimeout
public long getTimeout() -
isUseReplyTo
public boolean isUseReplyTo() -
getReplyDestinationName
-
getReplyMessageType
-
getReplyMessageTimeToLive
public long getReplyMessageTimeToLive() -
getReplyPriority
public int getReplyPriority() -
getReplyDeliveryMode
-
getSender
-
getForceMessageIdAsCorrelationId
-
isSoap
public boolean isSoap() -
getReplyEncodingStyleURI
-
getReplyNamespaceURI
-
getReplySoapAction
-
getSoapHeaderSessionKey
-