Class SimpleMessageConverter

All Implemented Interfaces:
MessageConverter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware

public class SimpleMessageConverter extends AllowedListDeserializingMessageConverter implements org.springframework.beans.factory.BeanClassLoaderAware
Implementation of MessageConverter that can work with Strings, Serializable instances, or byte arrays. The AbstractMessageConverter.toMessage(Object, MessageProperties) method simply checks the type of the provided instance while the fromMessage(Message) method relies upon the content-type of the provided Message.
  • Field Details

  • Constructor Details

    • SimpleMessageConverter

      public SimpleMessageConverter()
  • Method Details

    • setDefaultCharset

      public void setDefaultCharset(@Nullable String defaultCharset)
      Specify the default charset to use when converting to or from text-based Message body content. If not specified, the charset will be "UTF-8".
      Parameters:
      defaultCharset - The default charset.
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • fromMessage

      public Object fromMessage(Message message) throws MessageConversionException
      Converts from a AMQP Message to an 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
    • createMessage

      protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException
      Creates an AMQP Message from the provided Object.
      Specified by:
      createMessage in class AbstractMessageConverter
      Parameters:
      object - the payload.
      messageProperties - the message properties (headers).
      Returns:
      a message.
      Throws:
      MessageConversionException
    • createObjectInputStream

      protected ObjectInputStream createObjectInputStream(InputStream is) throws IOException
      Create an ObjectInputStream for the given InputStream. The default implementation creates an ConfigurableObjectInputStream against configured ClassLoader. The class for object to deserialize is checked against allowedListPatterns.
      Parameters:
      is - the InputStream to read from
      Returns:
      the new ObjectInputStream instance to use
      Throws:
      IOException - if creation of the ObjectInputStream failed