Spring AMQP

org.springframework.amqp.support.converter
Class AbstractMessageConverter

java.lang.Object
  extended by org.springframework.amqp.support.converter.AbstractMessageConverter
All Implemented Interfaces:
MessageConverter
Direct Known Subclasses:
JsonMessageConverter, MarshallingMessageConverter, SerializerMessageConverter, SimpleMessageConverter

public abstract class AbstractMessageConverter
extends Object
implements MessageConverter

Convenient base class for MessageConverter implementations.

Author:
Dave Syer

Constructor Summary
AbstractMessageConverter()
           
 
Method Summary
protected abstract  Message createMessage(Object object, MessageProperties messageProperties)
          Crate a message from the payload object and message properties provided.
abstract  Object fromMessage(Message message)
          Convert from a Message to a Java object.
protected  boolean isCreateMessageIds()
          Flag to indicate that new messages should have unique identifiers added to their properties before sending.
 void setCreateMessageIds(boolean createMessageIds)
          Flag to indicate that new messages should have unique identifiers added to their properties before sending.
 Message toMessage(Object object, MessageProperties messageProperties)
          Convert a Java object to a Message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessageConverter

public AbstractMessageConverter()
Method Detail

setCreateMessageIds

public void setCreateMessageIds(boolean createMessageIds)
Flag to indicate that new messages should have unique identifiers added to their properties before sending. Default false.

Parameters:
createMessageIds - the flag value to set

isCreateMessageIds

protected boolean isCreateMessageIds()
Flag to indicate that new messages should have unique identifiers added to their properties before sending.

Returns:
the flag value

toMessage

public final Message toMessage(Object object,
                               MessageProperties messageProperties)
                        throws MessageConversionException
Description copied from interface: MessageConverter
Convert a Java object to a Message.

Specified by:
toMessage in interface MessageConverter
Parameters:
object - the object to convert
Returns:
the Message
Throws:
MessageConversionException - in case of conversion failure

createMessage

protected abstract Message createMessage(Object object,
                                         MessageProperties messageProperties)
Crate a message from the payload object and message properties provided. The message id will be added to the properties if necessary later.

Parameters:
object - the payload
messageProperties - the message properties (headers)
Returns:
a message

fromMessage

public abstract Object fromMessage(Message message)
                            throws MessageConversionException
Description copied from interface: MessageConverter
Convert from a Message to a Java object.

Specified by:
fromMessage in interface MessageConverter
Parameters:
message - the message to convert
Returns:
the converted Java object
Throws:
MessageConversionException - in case of conversion failure

Spring AMQP

Copyright © 2011. All Rights Reserved.