Package org.frankframework.jms
Class JMSFacade
java.lang.Object
org.frankframework.jndi.JndiBase
org.frankframework.jms.JMSFacade
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IScopeProvider,IXAEnabled,NameAware,ConfigurableLifecycle,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
AbstractJmsListener,AbstractJmsMessageBrowser,JmsSender
@DestinationType(JMS)
public class JMSFacade
extends JndiBase
implements ConfigurableLifecycle, FrankElement, NameAware, HasPhysicalDestination, IXAEnabled
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
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enumstatic enumThe JMSMessageclass for the outgoing message.static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected org.apache.logging.log4j.Loggerprotected MessagingSourceFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidcloseSession(jakarta.jms.Session session) voidConfigure this component.protected jakarta.jms.MessagecreateBytesMessage(jakarta.jms.Session session, String correlationID, Message message) jakarta.jms.MessagecreateMessage(jakarta.jms.Session session, String correlationID, Message message) jakarta.jms.MessagecreateMessage(jakarta.jms.Session session, String correlationID, Message message, JMSFacade.MessageClass messageClass) protected jakarta.jms.SessionReturns a session on the connection for a topic or a queueprotected jakarta.jms.TextMessagecreateTextMessage(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 MessageextractMessageBody(Message message, Map<String, Object> context, SoapWrapper soapWrapper) getContext(jakarta.jms.Message message) jakarta.jms.Destinationjakarta.jms.DestinationgetDestination(String destinationName) protected JmsMessagingSourceprotected Stringjakarta.jms.MessageConsumergetMessageConsumer(jakarta.jms.Session session, jakarta.jms.Destination destination) Create a MessageConsumer, on a specific session and for a specific destination.jakarta.jms.MessageConsumergetMessageConsumer(jakarta.jms.Session session, jakarta.jms.Destination destination, String selector) Create a MessageConsumer.jakarta.jms.MessageConsumergetMessageConsumerForCorrelationId(jakarta.jms.Session session, jakarta.jms.Destination destination, String correlationId) Gets a MessageConsumer object for either Topics or Queues.jakarta.jms.MessageProducergetMessageProducer(jakarta.jms.Session session, jakarta.jms.Destination destination) protected MessagingSourcegetPhysicalDestinationShortName(boolean throwException) booleanbooleanprotected voidlogMessageDetails(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, boolean ignoreInvalidDestinationException, Map<String, Object> properties) protected StringsendByQueue(jakarta.jms.QueueSession session, jakarta.jms.Queue destination, jakarta.jms.Message message) protected StringsendByTopic(jakarta.jms.TopicSession session, jakarta.jms.Topic destination, jakarta.jms.Message message) voidsetAcknowledgeMode(JMSFacade.AcknowledgeMode acknowledgeMode) If not transacted, the way the application informs the JMS provider that it has successfully received a message.voidsetAuthAlias(String string) Alias used to obtain credentials for authentication to JMS servervoidsetCorrelationIdMaxLength(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 lengthvoidsetCorrelationIdToHex(boolean correlationIdToHex) Transform the value of the correlationid to a hexadecimal value if it starts with id: (preserving the id: part).voidsetCorrelationIdToHexPrefix(String correlationIdToHexPrefix) Prefix to check before executing correlationIdToHex.voidsetDestinationName(String destinationName) Name of the JMS destination (queue or topic) to usevoidsetDestinationType(JMSFacade.JmsDestinationType destinationType) Type of the messaging destination.voidsetJndiContextPrefix(String jndiContextPrefix) voidsetLookupDestination(boolean b) If setfalse, the destinationName is used directly instead of performing a JNDI lookupvoidsetMessageClass(JMSFacade.MessageClass messageClass) The JMSMessageclass for the outgoing message.voidsetMessageCorrelationID(jakarta.jms.Message message, String correlationID) voidsetMessageSelector(String newMessageSelector) If set, the value of this attribute is used as a selector to filter messages.voidsetMessageTimeToLive(long ttl) The time in milliseconds it takes for the message to expire.voidThe name of this FrankElementvoidsetPersistent(boolean value) Deprecated, for removal: This API element is subject to removal in a future version.voidUsed whendestinationType=QUEUE.voidsetSubscriberType(JMSFacade.SubscriberType subscriberType) Only applicable for topicsvoidsetTopicConnectionFactoryName(String topicConnectionFactoryName) Used whendestinationType=TOPIC.voidsetTransacted(boolean transacted) Controls whether messages are send under transaction control.voidstart()Obtains a connection and a serviceQueue.voidstop()Releases references to serviceQueue and connection.toString()Methods inherited from class org.frankframework.jndi.JndiBase
getContext, getJndiEnv, setAuthentication, setCredentials, setInitialContextFactoryName, setJmsRealm, setJndiAuthAlias, setJndiProperties, setPrincipal, setProviderURL, setSecurityProtocol, setUrlPkgPrefixesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.lifecycle.ConfigurableLifecycle
getPhase, isAutoStartup, isConfiguredMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.IXAEnabled
isTransactedMethods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log -
JMS_MESSAGECLASS_KEY
- See Also:
-
messagingSource
-
-
Constructor Details
-
JMSFacade
public JMSFacade()
-
-
Method Details
-
setMessageClass
The JMSMessageclass for the outgoing message. Currently supported areJMSFacade.MessageClass.TEXTfor JMSTextMessage,JMSFacade.MessageClass.BYTESfor JMSBytesMessage, orJMSFacade.MessageClass.AUTOfor auto-determination based on whether the inputMessageis binary or character.Defaults to
JMSFacade.MessageClass.AUTO, unless the default is overridden inAppConstantswith propertyjms.messageClass.default -
getLogPrefix
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
getConnectionFactoryName
- Throws:
JmsException
-
getJmsMessagingSource
- Throws:
JmsException
-
getMessagingSource
- Throws:
JmsException
-
setJndiContextPrefix
-
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.- Specified by:
startin interfaceConfigurableLifecycle- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()Releases references to serviceQueue and connection. -
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
createMessage
@Nonnull public jakarta.jms.Message createMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSExceptionIOException
-
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.JMSExceptionIOException
-
createBytesMessage
@Nonnull protected jakarta.jms.Message createBytesMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSExceptionIOException
-
createTextMessage
@Nonnull protected jakarta.jms.TextMessage createTextMessage(jakarta.jms.Session session, String correlationID, Message message) throws jakarta.jms.JMSException, IOException - Throws:
jakarta.jms.JMSExceptionIOException
-
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 thegetMessageConsumerForCorrelationIdshould be used, otherwise thegetMessageConsumerfunction 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:
getPhysicalDestinationNamein 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, boolean ignoreInvalidDestinationException, Map<String, Object> properties) throws jakarta.jms.JMSException, SenderException, IOException- Throws:
jakarta.jms.JMSExceptionSenderExceptionIOException
-
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 onlyTextMessages andBytesMessage.- Throws:
jakarta.jms.JMSExceptionSAXExceptionTransformerExceptionIOExceptionXmlException
-
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 messaging destination. This function also sets theuseTopicFunctionsfield, 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 aqueueifIXAEnabled.isTransacted()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 ifIXAEnabled.isTransacted()returnsfalse. The corresponding connection factory should be configured not to support XA transactions. -
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
-
setName
The name of this FrankElement
-