Class JmsBinding

java.lang.Object
org.apache.camel.component.jms.JmsBinding

public class JmsBinding extends Object
A Strategy used to convert between a Camel Exchange and JmsMessage to and from a JMS Message
  • Constructor Details

    • JmsBinding

      public JmsBinding()
    • JmsBinding

      public JmsBinding(JmsEndpoint endpoint)
  • Method Details

    • checkDeserializedClass

      protected void checkDeserializedClass(Object payload)
      Applies the configured (or default) deserialization filter to the class of an object returned by ObjectMessage.getObject(). Throws SecurityException if the class is rejected.

      Note: this check runs after the JMS provider has already deserialized the payload. It prevents unexpected classes from being propagated to the route, but it cannot, on its own, stop gadget chains whose readObject() fires inside the provider's ObjectInputStream. Complete protection requires configuring the JMS provider's own deserialization filter and/or the JVM-wide -Djdk.serialFilter.

    • extractBodyFromJms

      public Object extractBodyFromJms(org.apache.camel.Exchange exchange, jakarta.jms.Message message)
      Extracts the body from the JMS message
      Parameters:
      exchange - the exchange
      message - the message to extract its body
      Returns:
      the body, can be null
    • extractHeadersFromJms

      public Map<String,Object> extractHeadersFromJms(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange)
    • getObjectProperty

      @Deprecated public Object getObjectProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException
      Deprecated.
      not in use
      Throws:
      jakarta.jms.JMSException
    • createByteArrayFromBytesMessage

      protected Object createByteArrayFromBytesMessage(org.apache.camel.Exchange exchange, jakarta.jms.BytesMessage message) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createInputStreamFromStreamMessage

      protected Object createInputStreamFromStreamMessage(jakarta.jms.StreamMessage message)
    • makeJmsMessage

      public jakarta.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange, jakarta.jms.Session session) throws jakarta.jms.JMSException
      Creates a JMS message from the Camel exchange and message
      Parameters:
      exchange - the current exchange
      session - the JMS session used to create the message
      Returns:
      a newly created JMS Message instance containing the
      Throws:
      jakarta.jms.JMSException - if the message could not be created
    • makeJmsMessage

      public jakarta.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message camelMessage, jakarta.jms.Session session, Exception cause) throws jakarta.jms.JMSException
      Creates a JMS message from the Camel exchange and message
      Parameters:
      exchange - the current exchange
      camelMessage - the body to make a jakarta.jms.Message as
      session - the JMS session used to create the message
      cause - optional exception occurred that should be sent as reply instead of a regular body
      Returns:
      a newly created JMS Message instance containing the
      Throws:
      jakarta.jms.JMSException - if the message could not be created
    • appendJmsProperties

      public void appendJmsProperties(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange) throws jakarta.jms.JMSException
      Appends the JMS headers from the Camel JmsMessage
      Throws:
      jakarta.jms.JMSException
    • appendJmsProperties

      public void appendJmsProperties(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, org.apache.camel.Message in) throws jakarta.jms.JMSException
      Appends the JMS headers from the Camel JmsMessage
      Throws:
      jakarta.jms.JMSException
    • appendJmsProperty

      public void appendJmsProperty(jakarta.jms.Message jmsMessage, org.apache.camel.Exchange exchange, String headerName, Object headerValue) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • isStandardJMSHeader

      protected boolean isStandardJMSHeader(String headerName)
      Is the given header a standard JMS header
      Parameters:
      headerName - the header name
      Returns:
      true if its a standard JMS header
    • getValidJMSHeaderValue

      protected Object getValidJMSHeaderValue(String headerName, Object headerValue)
      Strategy to test if the given header is valid according to the JMS spec to be set as a property on the JMS message.

      This default implementation will allow:

      • any primitives and their counter Objects (Integer, Double etc.)
      • String and any other literals, Character, CharSequence
      • Boolean
      • Number
      • java.math.BigInteger
      • java.math.BigDecimal
      • java.util.Date
      Parameters:
      headerName - the header name
      headerValue - the header value
      Returns:
      the value to use, null to ignore this header
    • createJmsMessage

      protected jakarta.jms.Message createJmsMessage(Exception cause, jakarta.jms.Session session) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createJmsMessage

      protected jakarta.jms.Message createJmsMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message camelMessage, jakarta.jms.Session session, org.apache.camel.CamelContext context) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createJmsMessage

      protected jakarta.jms.Message createJmsMessage(org.apache.camel.Exchange exchange, Object body, Map<String,Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • getJMSMessageTypeForBody

      protected JmsMessageType getJMSMessageTypeForBody(org.apache.camel.Exchange exchange, Object body)
      Return the JmsMessageType
      Returns:
      type or null if no mapping was possible
    • createJmsMessageForType

      protected jakarta.jms.Message createJmsMessageForType(org.apache.camel.Exchange exchange, Object body, jakarta.jms.Session session, org.apache.camel.CamelContext context, JmsMessageType type) throws jakarta.jms.JMSException
      Create the Message
      Returns:
      jmsMessage or null if the mapping was not successfully
      Throws:
      jakarta.jms.JMSException
    • populateMapMessage

      protected void populateMapMessage(jakarta.jms.MapMessage message, Map<?,?> map, org.apache.camel.CamelContext context) throws jakarta.jms.JMSException
      Populates a MapMessage from a Map instance.
      Throws:
      jakarta.jms.JMSException
    • createMapFromMapMessage

      public Map<String,Object> createMapFromMapMessage(jakarta.jms.MapMessage message) throws jakarta.jms.JMSException
      Extracts a Map from a MapMessage
      Throws:
      jakarta.jms.JMSException
    • shouldOutputHeader

      protected boolean shouldOutputHeader(String headerName, Object headerValue, org.apache.camel.Exchange exchange)
      Strategy to allow filtering of headers which are put on the JMS message

      Note: Currently only supports sending java identifiers as keys