Class Message

java.lang.Object
org.springframework.amqp.core.Message
All Implemented Interfaces:
Serializable

public class Message extends Object implements Serializable
The 0-8 and 0-9-1 AMQP specifications do not define an Message class or interface. Instead, when performing an operation such as basicPublish the content is passed as a byte-array argument and additional properties are passed in as separate arguments. Spring AMQP defines a Message class as part of a more general AMQP domain model representation. The purpose of the Message class is to simply encapsulate the body and properties within a single instance so that the rest of the AMQP API can in turn be simpler.
Author:
Mark Pollack, Mark Fisher, Oleg Zhurakousky, Dave Syer, Gary Russell, Alex Panchenko, Artem Bilan
See Also:
  • Constructor Details

    • Message

      public Message(byte[] body)
      Construct an instance with the provided body and default MessageProperties.
      Parameters:
      body - the body.
      Since:
      2.2.17
    • Message

      public Message(byte[] body, MessageProperties messageProperties)
      Construct an instance with the provided body and properties.
      Parameters:
      body - the body.
      messageProperties - the properties.
  • Method Details

    • addAllowedListPatterns

      @Deprecated public static void addAllowedListPatterns(String... patterns)
      Deprecated.
      toString() no longer deserializes the body.
      No longer used.
      Parameters:
      patterns - the patterns.
      Since:
      1.5.7
    • setDefaultEncoding

      public static void setDefaultEncoding(String encoding)
      Set the encoding to use in toString() when converting the body if there is no contentEncoding message property present.
      Parameters:
      encoding - the encoding to use.
      Since:
      2.2.4
    • setMaxBodyLength

      public static void setMaxBodyLength(int length)
      Set the maximum length of a test message body to render as a String in toString(). Default 50.
      Parameters:
      length - the length to render.
      Since:
      2.2.20
    • getBody

      public byte[] getBody()
    • getMessageProperties

      public MessageProperties getMessageProperties()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object