Class JmsBinding

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

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

    • JmsBinding

      public JmsBinding(boolean mapJmsMessage, boolean allowNullBody, org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy, JmsKeyFormatStrategy jmsJmsKeyFormatStrategy, MessageCreatedStrategy messageCreatedStrategy)
  • Method Details

    • 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

      public Object getObjectProperty(jakarta.jms.Message jmsMessage, String name) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • createByteArrayFromBytesMessage

      protected byte[] createByteArrayFromBytesMessage(jakarta.jms.BytesMessage message) throws jakarta.jms.JMSException
      Throws:
      jakarta.jms.JMSException
    • 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, Map<String,Object> headers) throws jakarta.jms.JMSException
      Appends the JMS headers from the Camel Message
      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.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, 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, Map<String,Object> headers, jakarta.jms.Session session, org.apache.camel.CamelContext context)
      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