org.apache.camel.component.jms
Class JmsBinding

java.lang.Object
  extended by 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

Version:

Constructor Summary
JmsBinding()
           
JmsBinding(JmsEndpoint endpoint)
           
 
Method Summary
 void appendJmsProperties(javax.jms.Message jmsMessage, org.apache.camel.Exchange exchange)
          Appends the JMS headers from the Camel JmsMessage
 void appendJmsProperties(javax.jms.Message jmsMessage, org.apache.camel.Exchange exchange, org.apache.camel.Message in)
          Appends the JMS headers from the Camel JmsMessage
 void appendJmsProperty(javax.jms.Message jmsMessage, org.apache.camel.Exchange exchange, org.apache.camel.Message in, String headerName, Object headerValue)
           
protected  byte[] createByteArrayFromBytesMessage(javax.jms.BytesMessage message)
           
protected  javax.jms.Message createJmsMessage(Exception cause, javax.jms.Session session)
           
protected  javax.jms.Message createJmsMessage(org.apache.camel.Exchange exchange, Object body, Map<String,Object> headers, javax.jms.Session session, org.apache.camel.CamelContext context)
           
protected  javax.jms.Message createJmsMessageForType(org.apache.camel.Exchange exchange, Object body, Map<String,Object> headers, javax.jms.Session session, org.apache.camel.CamelContext context, JmsMessageType type)
          Create the Message
 Map<String,Object> createMapFromMapMessage(javax.jms.MapMessage message)
          Extracts a Map from a MapMessage
 Object extractBodyFromJms(org.apache.camel.Exchange exchange, javax.jms.Message message)
          Extracts the body from the JMS message
 Map<String,Object> extractHeadersFromJms(javax.jms.Message jmsMessage, org.apache.camel.Exchange exchange)
           
protected  JmsMessageType getJMSMessageTypeForBody(org.apache.camel.Exchange exchange, Object body, Map<String,Object> headers, javax.jms.Session session, org.apache.camel.CamelContext context)
          Return the JmsMessageType
 Object getObjectProperty(javax.jms.Message jmsMessage, String name)
           
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.
protected  boolean isStandardJMSHeader(String headerName)
          Is the given header a standard JMS header
 javax.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange, org.apache.camel.Message camelMessage, javax.jms.Session session, Exception cause)
          Creates a JMS message from the Camel exchange and message
 javax.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange, javax.jms.Session session)
          Creates a JMS message from the Camel exchange and message
protected  void populateMapMessage(javax.jms.MapMessage message, Map<?,?> map, org.apache.camel.CamelContext context)
          Populates a MapMessage from a Map instance.
protected  boolean shouldOutputHeader(org.apache.camel.Message camelMessage, 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

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmsBinding

public JmsBinding()

JmsBinding

public JmsBinding(JmsEndpoint endpoint)
Method Detail

extractBodyFromJms

public Object extractBodyFromJms(org.apache.camel.Exchange exchange,
                                 javax.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(javax.jms.Message jmsMessage,
                                                org.apache.camel.Exchange exchange)

getObjectProperty

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

createByteArrayFromBytesMessage

protected byte[] createByteArrayFromBytesMessage(javax.jms.BytesMessage message)
                                          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

makeJmsMessage

public javax.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange,
                                        javax.jms.Session session)
                                 throws javax.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:
javax.jms.JMSException - if the message could not be created

makeJmsMessage

public javax.jms.Message makeJmsMessage(org.apache.camel.Exchange exchange,
                                        org.apache.camel.Message camelMessage,
                                        javax.jms.Session session,
                                        Exception cause)
                                 throws javax.jms.JMSException
Creates a JMS message from the Camel exchange and message

Parameters:
exchange - the current exchange
camelMessage - the body to make a javax.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:
javax.jms.JMSException - if the message could not be created

appendJmsProperties

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

Throws:
javax.jms.JMSException

appendJmsProperties

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

Throws:
javax.jms.JMSException

appendJmsProperty

public void appendJmsProperty(javax.jms.Message jmsMessage,
                              org.apache.camel.Exchange exchange,
                              org.apache.camel.Message in,
                              String headerName,
                              Object headerValue)
                       throws javax.jms.JMSException
Throws:
javax.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:

Parameters:
headerName - the header name
headerValue - the header value
Returns:
the value to use, null to ignore this header

createJmsMessage

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

createJmsMessage

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

getJMSMessageTypeForBody

protected JmsMessageType getJMSMessageTypeForBody(org.apache.camel.Exchange exchange,
                                                  Object body,
                                                  Map<String,Object> headers,
                                                  javax.jms.Session session,
                                                  org.apache.camel.CamelContext context)
Return the JmsMessageType

Returns:
type or null if no mapping was possible

createJmsMessageForType

protected javax.jms.Message createJmsMessageForType(org.apache.camel.Exchange exchange,
                                                    Object body,
                                                    Map<String,Object> headers,
                                                    javax.jms.Session session,
                                                    org.apache.camel.CamelContext context,
                                                    JmsMessageType type)
                                             throws javax.jms.JMSException
Create the Message

Returns:
jmsMessage or null if the mapping was not successfully
Throws:
javax.jms.JMSException

populateMapMessage

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

Throws:
javax.jms.JMSException

createMapFromMapMessage

public Map<String,Object> createMapFromMapMessage(javax.jms.MapMessage message)
                                           throws javax.jms.JMSException
Extracts a Map from a MapMessage

Throws:
javax.jms.JMSException

shouldOutputHeader

protected boolean shouldOutputHeader(org.apache.camel.Message camelMessage,
                                     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



Apache Camel