Class AbstractMessageConverter

java.lang.Object
org.springframework.amqp.support.converter.AbstractMessageConverter
All Implemented Interfaces:
MessageConverter
Direct Known Subclasses:
AbstractJackson2MessageConverter, AllowedListDeserializingMessageConverter, MarshallingMessageConverter

public abstract class AbstractMessageConverter extends Object implements MessageConverter
Convenient base class for MessageConverter implementations.
Author:
Dave Syer, Gary Russell
  • Constructor Details

    • AbstractMessageConverter

      public AbstractMessageConverter()
  • Method Details

    • 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
      messageProperties - The message properties.
      Returns:
      the Message
      Throws:
      MessageConversionException - in case of conversion failure
    • toMessage

      public final Message toMessage(Object object, @Nullable MessageProperties messagePropertiesArg, @Nullable Type genericType) throws MessageConversionException
      Description copied from interface: MessageConverter
      Convert a Java object to a Message. The default implementation calls MessageConverter.toMessage(Object, MessageProperties).
      Specified by:
      toMessage in interface MessageConverter
      Parameters:
      object - the object to convert
      messagePropertiesArg - The message properties.
      genericType - the type to use to populate type headers.
      Returns:
      the Message
      Throws:
      MessageConversionException - in case of conversion failure
    • createMessage

      protected Message createMessage(Object object, MessageProperties messageProperties, @Nullable Type genericType)
      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)
      genericType - the type to convert from - used to populate type headers.
      Returns:
      a message
      Since:
      2.1
    • 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.