org.mule.providers.jms
Class JmsMessageAdapter

java.lang.Object
  extended by org.mule.providers.AbstractMessageAdapter
      extended by org.mule.providers.jms.JmsMessageAdapter
All Implemented Interfaces:
Serializable, ThreadSafeAccess, UMOMessageAdapter
Direct Known Subclasses:
OracleJmsMessageAdapter

public class JmsMessageAdapter
extends AbstractMessageAdapter

JmsMessageAdapter allows a MuleEvent 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

Field Summary
 
Fields inherited from class org.mule.providers.AbstractMessageAdapter
attachments, DEFAULT_FAILFAST, encoding, exceptionPayload, id, logger, properties, 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()
          By default we return "this".
 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.providers.AbstractMessageAdapter
addAttachment, addProperties, assertAccess, clearProperties, convertToBytes, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayloadAsString, getProperty, getProperty, getPropertyNames, getStringProperty, isDisabled, newException, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, 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 interface: UMOMessageAdapter
gets the unique identifier for the message. It's up to the implementation to ensure a unique id

Specified by:
getUniqueId in interface UMOMessageAdapter
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 UMOMessageAdapter
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 UMOMessageAdapter
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 UMOMessageAdapter
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 UMOMessageAdapter
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
By default we return "this". This allows older code to inter-operate but doesn't, of course, give the required safety. Subclasses should override this method. Re-writing the threading handling should remove this requirement....

Specified by:
newThreadCopy in interface ThreadSafeAccess
Overrides:
newThreadCopy in class AbstractMessageAdapter
Returns:
A new copy of this


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