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

public class JMSFacade extends JndiBase implements HasPhysicalDestination, IXAEnabled
Provides functions for jms connections, queues and topics and acts as a facade to hide for clients whether a Queue or Topic is used.
The destinationType field specifies which type should be used.
This class sends messages with JMS.
Author:
Gerrit van Brakel
  • Field Details

  • Constructor Details

    • JMSFacade

      public JMSFacade()
  • Method Details

    • setMessageClass

      public void setMessageClass(JMSFacade.MessageClass messageClass)
      The JMS Message class for the outgoing message. Currently supported are JMSFacade.MessageClass.TEXT for JMS TextMessage, JMSFacade.MessageClass.BYTES for JMS BytesMessage, or JMSFacade.MessageClass.AUTO for auto-determination based on whether the input Message is binary or character.

      Defaults to JMSFacade.MessageClass.AUTO, unless the default is overridden in AppConstants with property jms.messageClass.default

    • getLogPrefix

      protected String getLogPrefix()
    • configure

      public void configure() throws ConfigurationException
      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class JndiBase
      Throws:
      ConfigurationException
    • getConnectionFactoryName

      public String getConnectionFactoryName() throws JmsException
      Throws:
      JmsException
    • getConnectionFactoryInfo

      public String getConnectionFactoryInfo() throws JmsException
      Throws:
      JmsException
    • getJmsMessagingSource

      protected JmsMessagingSource getJmsMessagingSource() throws JmsException
      Throws:
      JmsException
    • getMessagingSourceFactory

      protected AbstractMessagingSourceFactory getMessagingSourceFactory()
    • getMessagingSource

      protected MessagingSource getMessagingSource() throws JmsException
      Throws:
      JmsException
    • createSession

      protected jakarta.jms.Session createSession() throws JmsException
      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.
      Overrides:
      stop in class JndiBase
    • 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

      public jakarta.jms.Destination getDestination() throws JmsException
      Throws:
      JmsException
    • getDestination

      public jakarta.jms.Destination getDestination(String destinationName)
    • 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 the getMessageConsumerForCorrelationId should be used, otherwise the getMessageConsumer function which has no attribute for selector. When a MessageSelector is set, it will be used when no correlation id is required.
      Parameters:
      session - the Session
      destination - the Destination
      selector - 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 Session
      destination - 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

      public String getPhysicalDestinationShortName()
    • getPhysicalDestinationShortName

      public String getPhysicalDestinationShortName(boolean throwException) throws JmsException
      Throws:
      JmsException
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • 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 - destination
      message -
      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

      public MessageContext getContext(jakarta.jms.Message message) throws jakarta.jms.JMSException
      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, XmlException
      Extracts string from message obtained from getRawMessage(Map). May also extract other parameters from the message and put those in the threadContext.

      Supports only TextMessages and BytesMessage.

      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
      Throws:
      SAXException
      TransformerException
      IOException
      XmlException
    • checkTransactionManagerValidity

      public void checkTransactionManagerValidity()
    • toString

      public String toString()
      Overrides:
      toString in class JndiBase
    • setDestinationName

      public void setDestinationName(String destinationName)
      Name of the JMS destination (queue or topic) to use
    • setDestinationType

      public void setDestinationType(JMSFacade.DestinationType destinationType)
      Type of the messageing destination. This function also sets the useTopicFunctions field, that controls whether Topic functions are used or Queue functions.
      Default value
      QUEUE
    • setAcknowledgeMode

      public void setAcknowledgeMode(JMSFacade.AcknowledgeMode acknowledgeMode)
      If not transacted, the way the application informs the JMS provider that it has successfully received a message.
      Default value
      auto
    • setPersistent

      @Deprecated(forRemoval=true, since="7.6.0") public void setPersistent(boolean value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Controls whether messages are processed persistently. When set true, the JMS provider ensures that messages aren't lost when the application might crash.
    • setSubscriberType

      public void setSubscriberType(JMSFacade.SubscriberType subscriberType)
      Only applicable for topics
      Default value
      DURABLE
    • setQueueConnectionFactoryName

      public void setQueueConnectionFactoryName(String name)
      Used when destinationType = QUEUE. The JNDI-name of the queueConnectionFactory to use to connect to a queue if isTransacted() returns false. The corresponding connection factory should be configured not to support XA transactions.
    • setTopicConnectionFactoryName

      public void setTopicConnectionFactoryName(String topicConnectionFactoryName)
      Used when destinationType = TOPIC. The JNDI-name of the connection factory to use to connect to a topic if isTransacted() returns false. The corresponding connection factory should be configured not to support XA transactions.
    • setJmsTransacted

      @Deprecated(forRemoval=true, since="7.6.0") public 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. 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'. The transacted 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 set true, 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

      public void setCorrelationIdToHexPrefix(String correlationIdToHexPrefix)
      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

      public void setMessageSelector(String newMessageSelector)
      If set, the value of this attribute is used as a selector to filter messages.
      Default value
      0 (unlimited)
    • setAuthAlias

      public void setAuthAlias(String string)
      Alias used to obtain credentials for authentication to JMS server
    • setLookupDestination

      public void setLookupDestination(boolean b)
      If set false, the destinationName is used directly instead of performing a JNDI lookup
      Default value
      true
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface HasPhysicalDestination
    • getMessageClass

      public JMSFacade.MessageClass getMessageClass()
    • isTransacted

      public boolean isTransacted()
      Description copied from interface: IXAEnabled
      indicates implementing object is under transaction control, using XA-transactions
      Specified by:
      isTransacted in interface IXAEnabled
    • isJmsTransacted

      public boolean isJmsTransacted()
    • getSubscriberType

      public JMSFacade.SubscriberType getSubscriberType()
    • getAcknowledgeMode

      public JMSFacade.AcknowledgeMode getAcknowledgeMode()
    • isPersistent

      public boolean isPersistent()
    • getMessageTimeToLive

      public long getMessageTimeToLive()
    • getDestinationName

      public String getDestinationName()
    • isUseTopicFunctions

      public boolean isUseTopicFunctions()
    • getAuthAlias

      public String getAuthAlias()
    • isLookupDestination

      public boolean isLookupDestination()
    • getDestinationType

      public JMSFacade.DestinationType getDestinationType()
    • setConnectionFactoryFactory

      public void setConnectionFactoryFactory(IConnectionFactoryFactory connectionFactoryFactory)
    • getConnectionFactoryFactory

      public IConnectionFactoryFactory getConnectionFactoryFactory()
    • setProxiedDestinationNames

      public void setProxiedDestinationNames(Map<String,String> proxiedDestinationNames)
    • getProxiedDestinationNames

      public Map<String,String> getProxiedDestinationNames()
    • getQueueConnectionFactoryName

      public String getQueueConnectionFactoryName()
    • getTopicConnectionFactoryName

      public String getTopicConnectionFactoryName()
    • getMessageSelector

      public String getMessageSelector()
    • isCorrelationIdToHex

      public boolean isCorrelationIdToHex()
    • getCorrelationIdToHexPrefix

      public String getCorrelationIdToHexPrefix()
    • getCorrelationIdMaxLength

      public int getCorrelationIdMaxLength()
    • getTxManager

      public org.springframework.transaction.PlatformTransactionManager getTxManager()
    • setTxManager

      public void setTxManager(org.springframework.transaction.PlatformTransactionManager txManager)