Package org.springframework.amqp.core
Class MessageBuilder
- java.lang.Object
-
- org.springframework.amqp.core.MessageBuilderSupport<Message>
-
- org.springframework.amqp.core.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageBuilder
andProperties(MessageProperties properties)
Makes this builder's properties builder use a reference to properties.Message
build()
static MessageBuilder
fromClonedMessage(Message message)
The final message will have a copy of the message body, the MessageProperties will be cloned (top level only).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.static MessageBuilder
withBody(byte[] body)
The final message body will be a direct reference to 'body'.static MessageBuilder
withBody(byte[] body, int from, int to)
The final message body will be a new array containing the byte range from 'body'.static MessageBuilder
withClonedBody(byte[] body)
The final message body will be a copy of 'body' in a new array.-
Methods inherited from class org.springframework.amqp.core.MessageBuilderSupport
buildProperties, copyHeaders, copyHeadersIfAbsent, copyProperties, removeHeader, removeHeaders, setAppId, setAppIdIfAbsent, setClusterId, setClusterIdIfAbsent, setContentEncoding, setContentEncodingIfAbsent, setContentLength, setContentLengthIfAbsent, setContentType, setContentTypeIfAbsentOrDefault, setCorrelationId, setCorrelationIdIfAbsent, setDeliveryMode, setDeliveryModeIfAbsentOrDefault, setDeliveryTag, setDeliveryTagIfAbsent, setExpiration, setExpirationIfAbsent, setHeader, setHeaderIfAbsent, setMessageCount, setMessageCountIfAbsent, setMessageId, setMessageIdIfAbsent, setPriority, setPriorityIfAbsentOrDefault, setProperties, setReceivedExchange, setReceivedExchangeIfAbsent, setReceivedRoutingKey, setReceivedRoutingKeyIfAbsent, setRedelivered, setRedeliveredIfAbsent, setReplyTo, setReplyToAddress, setReplyToAddressIfAbsent, setReplyToIfAbsent, setTimestamp, setTimestampIfAbsent, setType, setTypeIfAbsent, setUserId, setUserIdIfAbsent
-
-
-
-
Method Detail
-
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:
Arrays.copyOfRange(byte[], int, int)
-
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 classMessageBuilderSupport<Message>
-
-