org.apache.camel.component.jms
Class JmsMessage

java.lang.Object
  extended by org.apache.camel.impl.MessageSupport
      extended by org.apache.camel.impl.DefaultMessage
          extended by org.apache.camel.component.jms.JmsMessage
All Implemented Interfaces:
Message

public class JmsMessage
extends DefaultMessage

Represents a Message for working with JMS

Version:

Constructor Summary
JmsMessage(javax.jms.Message jmsMessage, JmsBinding binding)
           
 
Method Summary
 void copyFrom(Message that)
          Copies the contents of the other message into this message
protected  Object createBody()
          A factory method to allow a provider to lazily create the message body for inbound messages from other sources
 String createExchangeId()
          Returns the unique ID for a message exchange if this message is capable of creating one or null if not
protected  String createMessageId()
          Lets allow implementations to auto-create a messageId
protected  void ensureInitialHeaders()
          Ensure that the headers have been populated from the underlying JMS message before we start mutating the headers
 JmsBinding getBinding()
           
 Object getHeader(String name)
          Accesses a specific header
 Map<String,Object> getHeaders()
          Returns all of the headers associated with the message.
 javax.jms.Message getJmsMessage()
          Returns the underlying JMS message
 JmsMessage newInstance()
          Returns a new instance
protected  void populateInitialHeaders(Map<String,Object> map)
          A strategy method populate the initial set of headers on an inbound message from an underlying binding
 Object removeHeader(String name)
          Removes the named header from this message
 void setBinding(JmsBinding binding)
           
 void setBody(Object body)
          Sets the body of the message
 void setHeader(String name, Object value)
          Sets a header on the message
 void setHeaders(Map<String,Object> headers)
          Set all the headers associated with this message
 void setJmsMessage(javax.jms.Message jmsMessage)
           
 boolean shouldCreateNewMessage()
          Returns true if a new JMS message instance should be created to send to the next component
 String toString()
           
 
Methods inherited from class org.apache.camel.impl.DefaultMessage
addAttachment, createAttachments, createHeaders, getAttachment, getAttachmentNames, getAttachments, getHeader, getHeader, getHeader, hasAttachments, hasHeaders, hasPopulatedHeaders, isFault, populateInitialAttachments, removeAttachment, removeHeaders, removeHeaders, setAttachments, setFault
 
Methods inherited from class org.apache.camel.impl.MessageSupport
copy, getBody, getBody, getBody, getExchange, getMandatoryBody, getMandatoryBody, getMessageId, setBody, setExchange, setMessageId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JmsMessage

public JmsMessage(javax.jms.Message jmsMessage,
                  JmsBinding binding)
Method Detail

toString

public String toString()
Overrides:
toString in class DefaultMessage

copyFrom

public void copyFrom(Message that)
Description copied from interface: Message
Copies the contents of the other message into this message

Specified by:
copyFrom in interface Message
Overrides:
copyFrom in class DefaultMessage
Parameters:
that - the other message

getJmsMessage

public javax.jms.Message getJmsMessage()
Returns the underlying JMS message


getBinding

public JmsBinding getBinding()

setBinding

public void setBinding(JmsBinding binding)

setJmsMessage

public void setJmsMessage(javax.jms.Message jmsMessage)

setBody

public void setBody(Object body)
Description copied from interface: Message
Sets the body of the message

Specified by:
setBody in interface Message
Overrides:
setBody in class MessageSupport
Parameters:
body - the body

getHeader

public Object getHeader(String name)
Description copied from interface: Message
Accesses a specific header

Specified by:
getHeader in interface Message
Overrides:
getHeader in class DefaultMessage
Parameters:
name - name of header
Returns:
the value of the given header or null if there is no header for the given name

getHeaders

public Map<String,Object> getHeaders()
Description copied from interface: Message
Returns all of the headers associated with the message.

See DefaultMessage for how headers is represented in Camel using a CaseInsensitiveMap.

Important: If you want to walk the returned Map and fetch all the keys and values, you should use the Map.entrySet() method, which ensure you get the keys in the original case.

Specified by:
getHeaders in interface Message
Overrides:
getHeaders in class DefaultMessage
Returns:
all the headers in a Map

removeHeader

public Object removeHeader(String name)
Description copied from interface: Message
Removes the named header from this message

Specified by:
removeHeader in interface Message
Overrides:
removeHeader in class DefaultMessage
Parameters:
name - name of the header
Returns:
the old value of the header

setHeaders

public void setHeaders(Map<String,Object> headers)
Description copied from interface: Message
Set all the headers associated with this message

Specified by:
setHeaders in interface Message
Overrides:
setHeaders in class DefaultMessage
Parameters:
headers - headers to set

setHeader

public void setHeader(String name,
                      Object value)
Description copied from interface: Message
Sets a header on the message

Specified by:
setHeader in interface Message
Overrides:
setHeader in class DefaultMessage
Parameters:
name - of the header
value - to associate with the name

newInstance

public JmsMessage newInstance()
Description copied from class: MessageSupport
Returns a new instance

Overrides:
newInstance in class DefaultMessage

shouldCreateNewMessage

public boolean shouldCreateNewMessage()
Returns true if a new JMS message instance should be created to send to the next component


ensureInitialHeaders

protected void ensureInitialHeaders()
Ensure that the headers have been populated from the underlying JMS message before we start mutating the headers


createBody

protected Object createBody()
Description copied from class: MessageSupport
A factory method to allow a provider to lazily create the message body for inbound messages from other sources

Overrides:
createBody in class MessageSupport
Returns:
the value of the message body or null if there is no value available

populateInitialHeaders

protected void populateInitialHeaders(Map<String,Object> map)
Description copied from class: DefaultMessage
A strategy method populate the initial set of headers on an inbound message from an underlying binding

Overrides:
populateInitialHeaders in class DefaultMessage
Parameters:
map - is the empty header map to populate

createMessageId

protected String createMessageId()
Description copied from class: MessageSupport
Lets allow implementations to auto-create a messageId

Overrides:
createMessageId in class MessageSupport

createExchangeId

public String createExchangeId()
Description copied from interface: Message
Returns the unique ID for a message exchange if this message is capable of creating one or null if not

Specified by:
createExchangeId in interface Message
Overrides:
createExchangeId in class DefaultMessage
Returns:
the created exchange id, or null if not capable of creating


Apache CAMEL