org.mule.transport.jms
Class JmsMessageAdapter

java.lang.Object
  extended by org.mule.transport.AbstractMessageAdapter
      extended by org.mule.transport.jms.JmsMessageAdapter
All Implemented Interfaces:
Serializable, ThreadSafeAccess, MessageAdapter

public class JmsMessageAdapter
extends AbstractMessageAdapter

JmsMessageAdapter allows a DefaultMuleEvent to access the properties and payload of a JMS Message in a uniform way. The JmsMessageAdapter expects a message of type javax.jms.Message and will throw an IllegalArgumentException if the source message type is not compatible. The JmsMessageAdapter should be suitable for all JMS Connector implementations.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.mule.api.ThreadSafeAccess
ThreadSafeAccess.AccessControl
 
Field Summary
 
Fields inherited from class org.mule.transport.AbstractMessageAdapter
attachments, encoding, exceptionPayload, id, logger, properties
 
Fields inherited from interface org.mule.api.ThreadSafeAccess
READ, WRITE
 
Constructor Summary
protected JmsMessageAdapter(JmsMessageAdapter template)
           
  JmsMessageAdapter(Object message)
           
 
Method Summary
 String getCorrelationId()
          Sets a correlationId for this message.
 Object getPayload()
           
 byte[] getPayloadAsBytes()
          Converts the message implementation into a String representation
 String getPayloadAsString(String encoding)
          Converts the message implementation into a String representation
 Object getReplyTo()
          Sets a replyTo address for this message.
 String getUniqueId()
          gets the unique identifier for the message.
 ThreadSafeAccess newThreadCopy()
          
 void setCorrelationId(String id)
          Sets a correlationId for this message.
 void setReplyTo(Object replyTo)
          Sets a replyTo address for this message.
 void setSpecification(String newSpec)
           
 
Methods inherited from class org.mule.transport.AbstractMessageAdapter
addAttachment, addInboundProperties, addProperties, addProperties, assertAccess, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getProperty, getProperty, getPropertyNames, getStringProperty, isDisabled, newException, release, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setProperty, setStringProperty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JmsMessageAdapter

public JmsMessageAdapter(Object message)
                  throws MessagingException
Throws:
MessagingException

JmsMessageAdapter

protected JmsMessageAdapter(JmsMessageAdapter template)
Method Detail

setSpecification

public void setSpecification(String newSpec)

getPayloadAsString

public String getPayloadAsString(String encoding)
                          throws Exception
Converts the message implementation into a String representation

Parameters:
encoding - The encoding to use when transforming the message (if necessary). The parameter is used when converting from a byte array
Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPayloadAsBytes

public byte[] getPayloadAsBytes()
                         throws Exception
Converts the message implementation into a String representation

Returns:
String representation of the message
Throws:
Exception - Implemetation may throw an endpoint specific exception

getPayload

public Object getPayload()
Returns:
the current message

getUniqueId

public String getUniqueId()
Description copied from class: AbstractMessageAdapter
gets the unique identifier for the message. It's up to the implementation to ensure a unique id

Specified by:
getUniqueId in interface MessageAdapter
Overrides:
getUniqueId in class AbstractMessageAdapter
Returns:
a unique message id. The Id should never be null. If the underlying transport does not have the notion of a message Id, one shuold be generated. The generated Id should be a UUID.

setCorrelationId

public void setCorrelationId(String id)
Sets a correlationId for this message. The correlation Id can be used by components in the system to manage message relations

transport protocol. As such not all messages will support the notion of a correlationId i.e. tcp or file. In this situation the correlation Id is set as a property of the message where it's up to developer to keep the association with the message. For example if the message is serialised to xml the correlationId will be available in the message.

Specified by:
setCorrelationId in interface MessageAdapter
Overrides:
setCorrelationId in class AbstractMessageAdapter
Parameters:
id - the Id reference for this relationship

getCorrelationId

public String getCorrelationId()
Sets a correlationId for this message. The correlation Id can be used by components in the system to manage message relations.

The correlationId is associated with the message using the underlying transport protocol. As such not all messages will support the notion of a correlationId i.e. tcp or file. In this situation the correlation Id is set as a property of the message where it's up to developer to keep the association with the message. For example if the message is serialised to xml the correlationId will be available in the message.

Specified by:
getCorrelationId in interface MessageAdapter
Overrides:
getCorrelationId in class AbstractMessageAdapter
Returns:
the correlationId for this message or null if one hasn't been set

setReplyTo

public void setReplyTo(Object replyTo)
Sets a replyTo address for this message. This is useful in an asynchronous environment where the caller doesn't wait for a response and the response needs to be routed somewhere for further processing. The value of this field can be any valid endpointUri url.

Specified by:
setReplyTo in interface MessageAdapter
Overrides:
setReplyTo in class AbstractMessageAdapter
Parameters:
replyTo - the endpointUri url to reply to

getReplyTo

public Object getReplyTo()
Sets a replyTo address for this message. This is useful in an asynchronous environment where the caller doesn't wait for a response and the response needs to be routed somewhere for further processing. The value of this field can be any valid endpointUri url.

Specified by:
getReplyTo in interface MessageAdapter
Overrides:
getReplyTo in class AbstractMessageAdapter
Returns:
the endpointUri url to reply to or null if one has not been set

newThreadCopy

public ThreadSafeAccess newThreadCopy()
Description copied from class: AbstractMessageAdapter

Specified by:
newThreadCopy in interface ThreadSafeAccess
Overrides:
newThreadCopy in class AbstractMessageAdapter
Returns:
A new instance of the implementing class, unbound to any thread and mutable.


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.