Class MessageBuilder


public final class MessageBuilder extends MessageBuilderSupport<Message>
Builds a Spring AMQP Message either from a byte[] body or another Message using a fluent API.
Since:
1.3
Author:
Gary Russell
  • Method Details

    • withBody

      public static MessageBuilder withBody(byte[] body)
      The final message body will be a direct reference to 'body'.
      Parameters:
      body - The body.
      Returns:
      The builder.
    • withClonedBody

      public static MessageBuilder withClonedBody(byte[] body)
      The final message body will be a copy of 'body' in a new array.
      Parameters:
      body - The body.
      Returns:
      The builder.
    • withBody

      public static MessageBuilder withBody(byte[] body, int from, int to)
      The final message body will be a new array containing the byte range from 'body'.
      Parameters:
      body - The body.
      from - The starting index.
      to - The ending index.
      Returns:
      The builder.
      See Also:
    • fromMessage

      public static MessageBuilder fromMessage(Message message)
      The final message body will be a direct reference to the message body, the MessageProperties will be a shallow copy.
      Parameters:
      message - The message.
      Returns:
      The builder.
    • fromClonedMessage

      public static MessageBuilder fromClonedMessage(Message message)
      The final message will have a copy of the message body, the MessageProperties will be cloned (top level only).
      Parameters:
      message - The message.
      Returns:
      The builder.
    • andProperties

      public MessageBuilder andProperties(MessageProperties properties)
      Makes this builder's properties builder use a reference to properties.
      Parameters:
      properties - The properties.
      Returns:
      this.
    • build

      public Message build()
      Specified by:
      build in class MessageBuilderSupport<Message>