Package org.frankframework.jms
Class JMSFacade
java.lang.Object
org.frankframework.jndi.JndiBase
org.frankframework.jms.JMSFacade
- All Implemented Interfaces:
HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,IXAEnabled
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
AbstractJmsListener
,AbstractJmsMessageBrowser
,JmsSender
Provides functions for jms connections, queues and topics and acts as a facade
to hide for clients whether a
The
This class sends messages with JMS.
Queue
or Topic
is used.
The
destinationType
field specifies which
type should be used.This class sends messages with JMS.
- Author:
- Gerrit van Brakel
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static enum
static enum
The JMSMessage
class for the outgoing message.static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
closeSession
(jakarta.jms.Session session) void
protected jakarta.jms.Message
createBytesMessage
(jakarta.jms.Session session, String correlationID, Message message) jakarta.jms.Message
createMessage
(jakarta.jms.Session session, String correlationID, Message message) jakarta.jms.Message
createMessage
(jakarta.jms.Session session, String correlationID, Message message, JMSFacade.MessageClass messageClass) protected jakarta.jms.Session
Returns a session on the connection for a topic or a queueprotected jakarta.jms.TextMessage
createTextMessage
(jakarta.jms.Session session, String correlationID, Message message) extractMessage
(jakarta.jms.Message jmsMessage, Map<String, Object> context, boolean soap, String soapHeaderSessionKey, SoapWrapper soapWrapper) Extracts string from message obtained from getRawMessage(Map).protected Message
extractMessageBody
(Message message, Map<String, Object> context, SoapWrapper soapWrapper) getContext
(jakarta.jms.Message message) int
jakarta.jms.Destination
jakarta.jms.Destination
getDestination
(String destinationName) protected JmsMessagingSource
protected String
jakarta.jms.MessageConsumer
getMessageConsumer
(jakarta.jms.Session session, jakarta.jms.Destination destination) Create a MessageConsumer, on a specific session and for a specific destination.jakarta.jms.MessageConsumer
getMessageConsumer
(jakarta.jms.Session session, jakarta.jms.Destination destination, String selector) Create a MessageConsumer.jakarta.jms.MessageConsumer
getMessageConsumerForCorrelationId
(jakarta.jms.Session session, jakarta.jms.Destination destination, String correlationId) Gets a MessageConsumer object for either Topics or Queues.jakarta.jms.MessageProducer
getMessageProducer
(jakarta.jms.Session session, jakarta.jms.Destination destination) long
protected MessagingSource
protected AbstractMessagingSourceFactory
getPhysicalDestinationShortName
(boolean throwException) org.springframework.transaction.PlatformTransactionManager
boolean
boolean
boolean
boolean
boolean
boolean
indicates implementing object is under transaction control, using XA-transactionsboolean
protected void
logMessageDetails
(jakarta.jms.Message message, jakarta.jms.MessageProducer messageProducer) send
(jakarta.jms.MessageProducer messageProducer, jakarta.jms.Message message) Send a messagesend
(jakarta.jms.MessageProducer messageProducer, jakarta.jms.Message message, boolean ignoreInvalidDestinationException) send
(jakarta.jms.Session session, jakarta.jms.Destination dest, jakarta.jms.Message message) Send a messagesend
(jakarta.jms.Session session, jakarta.jms.Destination dest, jakarta.jms.Message message, boolean ignoreInvalidDestinationException) send
(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority) send
(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException) send
(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException, Map<String, Object> properties) protected String
sendByQueue
(jakarta.jms.QueueSession session, jakarta.jms.Queue destination, jakarta.jms.Message message) protected String
sendByTopic
(jakarta.jms.TopicSession session, jakarta.jms.Topic destination, jakarta.jms.Message message) void
setAcknowledgeMode
(JMSFacade.AcknowledgeMode acknowledgeMode) If not transacted, the way the application informs the JMS provider that it has successfully received a message.void
setAuthAlias
(String string) Alias used to obtain credentials for authentication to JMS servervoid
setConnectionFactoryFactory
(IConnectionFactoryFactory connectionFactoryFactory) void
setCorrelationIdMaxLength
(int i) If set (>=0) and the length of the correlationId exceeds this maximum length, the correlationId is trimmed from the left side of a string to this maximum lengthvoid
setCorrelationIdToHex
(boolean correlationIdToHex) Transform the value of the correlationid to a hexadecimal value if it starts with id: (preserving the id: part).void
setCorrelationIdToHexPrefix
(String correlationIdToHexPrefix) Prefix to check before executing correlationIdToHex.void
setDestinationName
(String destinationName) Name of the JMS destination (queue or topic) to usevoid
setDestinationType
(JMSFacade.DestinationType destinationType) Type of the messageing destination.void
setJmsTransacted
(boolean jmsTransacted) Deprecated, for removal: This API element is subject to removal in a future version.This attribute has been added to provide the pre-4.1 transaction functionality to configurations that relied this specific functionality.void
setLookupDestination
(boolean b) If setfalse
, the destinationName is used directly instead of performing a JNDI lookupvoid
setMessageClass
(JMSFacade.MessageClass messageClass) The JMSMessage
class for the outgoing message.void
setMessageCorrelationID
(jakarta.jms.Message message, String correlationID) void
setMessageSelector
(String newMessageSelector) If set, the value of this attribute is used as a selector to filter messages.void
setMessageTimeToLive
(long ttl) The time in milliseconds it takes for the message to expire.void
setPersistent
(boolean value) Deprecated, for removal: This API element is subject to removal in a future version.void
setProxiedDestinationNames
(Map<String, String> proxiedDestinationNames) void
Used whendestinationType
=QUEUE
.void
setSubscriberType
(JMSFacade.SubscriberType subscriberType) Only applicable for topicsvoid
setTopicConnectionFactoryName
(String topicConnectionFactoryName) Used whendestinationType
=TOPIC
.void
setTransacted
(boolean transacted) Controls whether messages are send under transaction control.void
setTxManager
(org.springframework.transaction.PlatformTransactionManager txManager) void
start()
Obtains a connection and a serviceQueue.void
stop()
Releases references to serviceQueue and connection.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
-
Field Details
-
JMS_MESSAGECLASS_KEY
- See Also:
-
messagingSource
-
-
Constructor Details
-
JMSFacade
public JMSFacade()
-
-
Method Details
-
setMessageClass
The JMSMessage
class for the outgoing message. Currently supported areJMSFacade.MessageClass.TEXT
for JMSTextMessage
,JMSFacade.MessageClass.BYTES
for JMSBytesMessage
, orJMSFacade.MessageClass.AUTO
for auto-determination based on whether the inputMessage
is binary or character.Defaults to
JMSFacade.MessageClass.AUTO
, unless the default is overridden inAppConstants
with propertyjms.messageClass.default
-
getLogPrefix
-
configure
- Specified by:
configure
in interfaceIConfigurable
- Overrides:
configure
in classJndiBase
- Throws:
ConfigurationException
-
getConnectionFactoryName
- Throws:
JmsException
-
getConnectionFactoryInfo
- Throws:
JmsException
-
getJmsMessagingSource
- Throws:
JmsException
-
getMessagingSourceFactory
-
getMessagingSource
- Throws:
JmsException
-
createSession
Returns a session on the connection for a topic or a queue- Throws:
JmsException
-
closeSession
protected void closeSession(jakarta.jms.Session session) -
start
public void start()Obtains a connection and a serviceQueue. -
stop
public void stop()Releases references to serviceQueue and connection. -
createMessage
@Nonnull public jakarta.jms.Message createMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSException
IOException
-
createMessage
@Nonnull public jakarta.jms.Message createMessage(jakarta.jms.Session session, String correlationID, Message message, JMSFacade.MessageClass messageClass) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSException
IOException
-
createBytesMessage
@Nonnull protected jakarta.jms.Message createBytesMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSException
IOException
-
createTextMessage
@Nonnull protected jakarta.jms.TextMessage createTextMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSException
IOException
-
setMessageCorrelationID
public void setMessageCorrelationID(jakarta.jms.Message message, String correlationID) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getDestination
- Throws:
JmsException
-
getDestination
-
getMessageConsumerForCorrelationId
public jakarta.jms.MessageConsumer getMessageConsumerForCorrelationId(jakarta.jms.Session session, jakarta.jms.Destination destination, String correlationId) throws jakarta.jms.JMSException Gets a MessageConsumer object for either Topics or Queues.- Returns:
- a MessageConsumer with the right filter (messageSelector)
- Throws:
jakarta.jms.JMSException
-
getMessageConsumer
public jakarta.jms.MessageConsumer getMessageConsumer(jakarta.jms.Session session, jakarta.jms.Destination destination, String selector) throws jakarta.jms.JMSException Create a MessageConsumer. In this overloaded function the selector is taken into account. This ensures that listeners (or other extensions of this class) do not influence how the selector is used: when a correlationID should be in the filter thegetMessageConsumerForCorrelationId
should be used, otherwise thegetMessageConsumer
function which has no attribute forselector
. When a MessageSelector is set, it will be used when no correlation id is required.- Parameters:
session
- the Sessiondestination
- the Destinationselector
- the MessageSelector- Returns:
- MessageConsumer
- Throws:
jakarta.jms.JMSException
-
getMessageConsumer
public jakarta.jms.MessageConsumer getMessageConsumer(jakarta.jms.Session session, jakarta.jms.Destination destination) throws jakarta.jms.JMSException Create a MessageConsumer, on a specific session and for a specific destination. This functions hides wether we work via Topics or Queues and whether a messageSelector is set.- Parameters:
session
- the Sessiondestination
- the Destination- Returns:
- the MessageConsumer
- Throws:
jakarta.jms.JMSException
-
getMessageProducer
public jakarta.jms.MessageProducer getMessageProducer(jakarta.jms.Session session, jakarta.jms.Destination destination) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
getPhysicalDestinationShortName
-
getPhysicalDestinationShortName
- Throws:
JmsException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
send
public String send(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority) throws jakarta.jms.JMSException, SenderException, IOException - Throws:
jakarta.jms.JMSException
SenderException
IOException
-
send
public String send(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException) throws jakarta.jms.JMSException, SenderException, IOException - Throws:
jakarta.jms.JMSException
SenderException
IOException
-
send
public String send(jakarta.jms.Session session, jakarta.jms.Destination dest, String correlationId, Message message, String messageType, long timeToLive, int deliveryMode, int priority, boolean ignoreInvalidDestinationException, Map<String, Object> properties) throws jakarta.jms.JMSException, SenderException, IOException- Throws:
jakarta.jms.JMSException
SenderException
IOException
-
send
public String send(jakarta.jms.MessageProducer messageProducer, jakarta.jms.Message message) throws jakarta.jms.JMSException Send a message- Parameters:
messageProducer
-message
-- Returns:
- messageID of sent message
- Throws:
jakarta.jms.JMSException
-
send
public String send(jakarta.jms.MessageProducer messageProducer, jakarta.jms.Message message, boolean ignoreInvalidDestinationException) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
logMessageDetails
protected void logMessageDetails(jakarta.jms.Message message, jakarta.jms.MessageProducer messageProducer) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
send
public String send(jakarta.jms.Session session, jakarta.jms.Destination dest, jakarta.jms.Message message) throws jakarta.jms.JMSException Send a message- Parameters:
session
-dest
- destinationmessage
-- Returns:
- message ID of the sent message
- Throws:
jakarta.jms.JMSException
-
send
public String send(jakarta.jms.Session session, jakarta.jms.Destination dest, jakarta.jms.Message message, boolean ignoreInvalidDestinationException) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
sendByQueue
protected String sendByQueue(jakarta.jms.QueueSession session, jakarta.jms.Queue destination, jakarta.jms.Message message) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
sendByTopic
protected String sendByTopic(jakarta.jms.TopicSession session, jakarta.jms.Topic destination, jakarta.jms.Message message) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
isSessionsArePooled
public boolean isSessionsArePooled() -
getContext
- Throws:
jakarta.jms.JMSException
-
extractMessage
public Message extractMessage(jakarta.jms.Message jmsMessage, Map<String, Object> context, boolean soap, String soapHeaderSessionKey, SoapWrapper soapWrapper) throws jakarta.jms.JMSException, SAXException, TransformerException, IOException, XmlExceptionExtracts string from message obtained from getRawMessage(Map). May also extract other parameters from the message and put those in the threadContext.
Supports onlyTextMessage
s andBytesMessage
.- Throws:
jakarta.jms.JMSException
SAXException
TransformerException
IOException
XmlException
-
extractMessageBody
protected Message extractMessageBody(Message message, Map<String, Object> context, SoapWrapper soapWrapper) throws SAXException, TransformerException, IOException, XmlException -
checkTransactionManagerValidity
public void checkTransactionManagerValidity() -
toString
-
setDestinationName
Name of the JMS destination (queue or topic) to use -
setDestinationType
Type of the messageing destination. This function also sets theuseTopicFunctions
field, that controls whether Topic functions are used or Queue functions.- Default value
- QUEUE
-
setAcknowledgeMode
If not transacted, the way the application informs the JMS provider that it has successfully received a message.- Default value
- auto
-
setPersistent
Deprecated, for removal: This API element is subject to removal in a future version.Controls whether messages are processed persistently. When settrue
, the JMS provider ensures that messages aren't lost when the application might crash. -
setSubscriberType
Only applicable for topics- Default value
- DURABLE
-
setQueueConnectionFactoryName
Used whendestinationType
=QUEUE
. The JNDI-name of the queueConnectionFactory to use to connect to aqueue
ifisTransacted()
returnsfalse
. The corresponding connection factory should be configured not to support XA transactions. -
setTopicConnectionFactoryName
Used whendestinationType
=TOPIC
. The JNDI-name of the connection factory to use to connect to a topic ifisTransacted()
returnsfalse
. The corresponding connection factory should be configured not to support XA transactions. -
setJmsTransacted
Deprecated, for removal: This API element is subject to removal in a future version.This attribute has been added to provide the pre-4.1 transaction functionality to configurations that relied this specific functionality. New configurations should not use it.Controls the use of JMS transacted session. In versions prior to 4.1, this attribute was called plainly 'transacted'. Thetransacted
attribute, however, is now in uses to indicate the use of XA-transactions. XA transactions can be used in a pipeline to simultaneously (in one transaction) commit or rollback messages send to a number of queues, or even together with database actions.- Since:
- 4.1
-
setTransacted
public void setTransacted(boolean transacted) Controls whether messages are send under transaction control. If settrue
, messages are committed or rolled back under control of an XA-transaction.- Default value
- false
-
setCorrelationIdToHex
public void setCorrelationIdToHex(boolean correlationIdToHex) Transform the value of the correlationid to a hexadecimal value if it starts with id: (preserving the id: part). Useful when sending messages to MQ which expects this value to be in hexadecimal format when it starts with id:, otherwise generating the error: MQJMS1044: String is not a valid hexadecimal number- Default value
- false
-
setCorrelationIdToHexPrefix
Prefix to check before executing correlationIdToHex. If empty (and correlationIdToHex equals true) all correlationid's are transformed, this is useful in case you want the entire correlationId to be transformed (for example when the receiving party doesn't allow characters like a colon to be present in the correlationId).- Default value
- id:
-
setMessageTimeToLive
public void setMessageTimeToLive(long ttl) The time in milliseconds it takes for the message to expire. If the message is not consumed before, it will be lost. Must be a positive value for request/reply type of messages, 0 disables the expiry timeout- Default value
- 0
-
setCorrelationIdMaxLength
public void setCorrelationIdMaxLength(int i) If set (>=0) and the length of the correlationId exceeds this maximum length, the correlationId is trimmed from the left side of a string to this maximum length- Default value
- -1
-
setMessageSelector
If set, the value of this attribute is used as a selector to filter messages.- Default value
- 0 (unlimited)
-
setAuthAlias
Alias used to obtain credentials for authentication to JMS server -
setLookupDestination
public void setLookupDestination(boolean b) If setfalse
, the destinationName is used directly instead of performing a JNDI lookup- Default value
- true
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getMessageClass
-
isTransacted
public boolean isTransacted()Description copied from interface:IXAEnabled
indicates implementing object is under transaction control, using XA-transactions- Specified by:
isTransacted
in interfaceIXAEnabled
-
isJmsTransacted
public boolean isJmsTransacted() -
getSubscriberType
-
getAcknowledgeMode
-
isPersistent
public boolean isPersistent() -
getMessageTimeToLive
public long getMessageTimeToLive() -
getDestinationName
-
isUseTopicFunctions
public boolean isUseTopicFunctions() -
getAuthAlias
-
isLookupDestination
public boolean isLookupDestination() -
getDestinationType
-
setConnectionFactoryFactory
-
getConnectionFactoryFactory
-
setProxiedDestinationNames
-
getProxiedDestinationNames
-
getQueueConnectionFactoryName
-
getTopicConnectionFactoryName
-
getMessageSelector
-
isCorrelationIdToHex
public boolean isCorrelationIdToHex() -
getCorrelationIdToHexPrefix
-
getCorrelationIdMaxLength
public int getCorrelationIdMaxLength() -
getTxManager
public org.springframework.transaction.PlatformTransactionManager getTxManager() -
setTxManager
public void setTxManager(org.springframework.transaction.PlatformTransactionManager txManager)
-