Class JmsMessageHelper

java.lang.Object
org.apache.camel.component.sjms.jms.JmsMessageHelper

public final class JmsMessageHelper extends Object
Utility class for Message.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.camel.trait.message.RedeliveryTraitPayload
    evalRedeliveryMessageTrait(jakarta.jms.Message message)
    For a given message, evaluates what is the redelivery state for it and gives the appropriate MessageTrait for that redelivery state
    static String
    getJMSCorrelationID(jakarta.jms.Message message)
    Gets the JMSCorrelationID from the message.
    static String
    getJMSCorrelationIDAsBytes(jakarta.jms.Message message)
    Gets the JMSCorrelationIDAsBytes from the message.
    static jakarta.jms.Destination
    getJMSDestination(jakarta.jms.Message message)
    Gets the JMSDestination from the message.
    static String
    getJMSMessageID(jakarta.jms.Message message)
    Gets the JMSMessageID from the message.
    static Boolean
    getJMSRedelivered(jakarta.jms.Message message)
    Gets the JMSRedelivered from the message.
    static jakarta.jms.Destination
    getJMSReplyTo(jakarta.jms.Message message)
    Gets the JMSReplyTo from the message.
    static String
    getJMSType(jakarta.jms.Message message)
    Gets the JMSType from the message.
    static Object
    getProperty(jakarta.jms.Message jmsMessage, String name)
    Gets a JMS property
    static String
    getStringProperty(jakarta.jms.Message message, String propertyName)
    Gets the String Properties from the message.
    static boolean
    hasProperty(jakarta.jms.Message jmsMessage, String name)
    Tests whether a given property with the name exists
    static boolean
    isQueuePrefix(String destination)
    Whether the destination name has either queue or temp queue prefix.
    static boolean
    isTopicPrefix(String destination)
    Whether the destination name has either topic or temp topic prefix.
    static String
    Normalizes the destination name.
    static String
    normalizeDestinationName(String destination, boolean includePrefix)
    Normalizes the destination name.
    static Object
    removeJmsProperty(jakarta.jms.Message jmsMessage, String name)
    Removes the property from the JMS message.
    static void
    setCorrelationId(jakarta.jms.Message message, String correlationId)
    Sets the correlation id on the JMS message.
    static void
    setJMSDeliveryMode(org.apache.camel.Exchange exchange, jakarta.jms.Message message, Object deliveryMode)
    Sets the JMSDeliveryMode on the message.
    static void
    setJMSReplyTo(jakarta.jms.Message message, jakarta.jms.Destination replyTo)
    Sets the JMSReplyTo on the message.
    static void
    setProperty(jakarta.jms.Message jmsMessage, String name, Object value)
    Sets the property on the given JMS message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • removeJmsProperty

      public static Object removeJmsProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException
      Removes the property from the JMS message.
      Parameters:
      jmsMessage - the JMS message
      name - name of the property to remove
      Returns:
      the old value of the property or null if not exists
      Throws:
      jakarta.jms.JMSException - can be thrown
    • hasProperty

      public static boolean hasProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException
      Tests whether a given property with the name exists
      Parameters:
      jmsMessage - the JMS message
      name - name of the property to test if exists
      Returns:
      true if the property exists, false if not.
      Throws:
      jakarta.jms.JMSException - can be thrown
    • getProperty

      public static Object getProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException
      Gets a JMS property
      Parameters:
      jmsMessage - the JMS message
      name - name of the property to get
      Returns:
      the property value, or null if does not exist
      Throws:
      jakarta.jms.JMSException - can be thrown
    • setProperty

      public static void setProperty(jakarta.jms.Message jmsMessage, String name, Object value) throws jakarta.jms.JMSException
      Sets the property on the given JMS message.
      Parameters:
      jmsMessage - the JMS message
      name - name of the property to set
      value - the value
      Throws:
      jakarta.jms.JMSException - can be thrown
    • setCorrelationId

      public static void setCorrelationId(jakarta.jms.Message message, String correlationId)
      Sets the correlation id on the JMS message.

      Will ignore exception thrown

      Parameters:
      message - the JMS message
      correlationId - the correlation id
    • isQueuePrefix

      public static boolean isQueuePrefix(String destination)
      Whether the destination name has either queue or temp queue prefix.
      Parameters:
      destination - the destination
      Returns:
      true if queue or temp-queue prefix, false otherwise
    • isTopicPrefix

      public static boolean isTopicPrefix(String destination)
      Whether the destination name has either topic or temp topic prefix.
      Parameters:
      destination - the destination
      Returns:
      true if topic or temp-topic prefix, false otherwise
    • normalizeDestinationName

      public static String normalizeDestinationName(String destination)
      Normalizes the destination name.

      This ensures the destination name is correct, and we do not create queues as queue://queue:foo, which was intended as queue://foo.

      Parameters:
      destination - the destination
      Returns:
      the normalized destination
    • normalizeDestinationName

      public static String normalizeDestinationName(String destination, boolean includePrefix)
      Normalizes the destination name.

      This ensures the destination name is correct, and we do not create queues as queue://queue:foo, which was intended as queue://foo.

      Parameters:
      destination - the destination
      includePrefix - whether to include queue://, or topic:// prefix in the normalized destination name
      Returns:
      the normalized destination
    • setJMSReplyTo

      public static void setJMSReplyTo(jakarta.jms.Message message, jakarta.jms.Destination replyTo)
      Sets the JMSReplyTo on the message.
      Parameters:
      message - the message
      replyTo - the reply to destination
    • getJMSReplyTo

      public static jakarta.jms.Destination getJMSReplyTo(jakarta.jms.Message message)
      Gets the JMSReplyTo from the message.
      Parameters:
      message - the message
      Returns:
      the reply to, can be null
    • getJMSType

      public static String getJMSType(jakarta.jms.Message message)
      Gets the JMSType from the message.
      Parameters:
      message - the message
      Returns:
      the type, can be null
    • getStringProperty

      public static String getStringProperty(jakarta.jms.Message message, String propertyName)
      Gets the String Properties from the message.
      Parameters:
      message - the message
      Returns:
      the type, can be null
    • getJMSRedelivered

      public static Boolean getJMSRedelivered(jakarta.jms.Message message)
      Gets the JMSRedelivered from the message.
      Parameters:
      message - the message
      Returns:
      true if redelivered, false if not, null if not able to determine
    • evalRedeliveryMessageTrait

      public static org.apache.camel.trait.message.RedeliveryTraitPayload evalRedeliveryMessageTrait(jakarta.jms.Message message)
      For a given message, evaluates what is the redelivery state for it and gives the appropriate MessageTrait for that redelivery state
      Parameters:
      message - the message to evalute
      Returns:
      The appropriate MessageTrait for the redelivery state (one of MessageTrait.UNDEFINED_REDELIVERY, MessageTrait.IS_REDELIVERY or MessageTrait.NON_REDELIVERY).
    • getJMSMessageID

      public static String getJMSMessageID(jakarta.jms.Message message)
      Gets the JMSMessageID from the message.
      Parameters:
      message - the message
      Returns:
      the JMSMessageID, or null if not able to get
    • setJMSDeliveryMode

      public static void setJMSDeliveryMode(org.apache.camel.Exchange exchange, jakarta.jms.Message message, Object deliveryMode) throws jakarta.jms.JMSException
      Sets the JMSDeliveryMode on the message.
      Parameters:
      exchange - the exchange
      message - the message
      deliveryMode - the delivery mode, either as a String or integer
      Throws:
      jakarta.jms.JMSException - is thrown if error setting the delivery mode
    • getJMSCorrelationID

      public static String getJMSCorrelationID(jakarta.jms.Message message)
      Gets the JMSCorrelationID from the message.
      Parameters:
      message - the message
      Returns:
      the JMSCorrelationID, or null if not able to get
    • getJMSCorrelationIDAsBytes

      public static String getJMSCorrelationIDAsBytes(jakarta.jms.Message message)
      Gets the JMSCorrelationIDAsBytes from the message.
      Parameters:
      message - the message
      Returns:
      the JMSCorrelationIDAsBytes, or null if not able to get
    • getJMSDestination

      public static jakarta.jms.Destination getJMSDestination(jakarta.jms.Message message)
      Gets the JMSDestination from the message.
      Parameters:
      message - the message
      Returns:
      the JMSDestination, or null if not able to get