public final class MessageBuilder<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
Message<T> |
build() |
MessageBuilder<T> |
copyHeaders(java.util.Map<java.lang.String,?> headersToCopy)
Copy the name-value pairs from the provided Map.
|
MessageBuilder<T> |
copyHeadersIfAbsent(java.util.Map<java.lang.String,?> headersToCopy)
Copy the name-value pairs from the provided Map.
|
static <T> MessageBuilder<T> |
fromMessage(Message<T> message)
Create a builder for a new
Message instance pre-populated with all of the headers copied from the
provided message. |
MessageBuilder<T> |
popSequenceDetails() |
MessageBuilder<T> |
pushSequenceDetails(java.lang.Object correlationId,
int sequenceNumber,
int sequenceSize) |
MessageBuilder<T> |
removeHeader(java.lang.String headerName)
Remove the value for the given header name.
|
MessageBuilder<T> |
removeHeaders(java.lang.String... headerPatterns)
Removes all headers provided via array of 'headerPatterns'.
|
MessageBuilder<T> |
setCorrelationId(java.lang.Object correlationId) |
MessageBuilder<T> |
setErrorChannel(MessageChannel errorChannel) |
MessageBuilder<T> |
setErrorChannelName(java.lang.String errorChannelName) |
MessageBuilder<T> |
setExpirationDate(java.util.Date expirationDate) |
MessageBuilder<T> |
setExpirationDate(java.lang.Long expirationDate) |
MessageBuilder<T> |
setHeader(java.lang.String headerName,
java.lang.Object headerValue)
Set the value for the given header name.
|
MessageBuilder<T> |
setHeaderIfAbsent(java.lang.String headerName,
java.lang.Object headerValue)
Set the value for the given header name only if the header name is not already associated with a value.
|
MessageBuilder<T> |
setPriority(java.lang.Integer priority) |
MessageBuilder<T> |
setReplyChannel(MessageChannel replyChannel) |
MessageBuilder<T> |
setReplyChannelName(java.lang.String replyChannelName) |
MessageBuilder<T> |
setSequenceNumber(java.lang.Integer sequenceNumber) |
MessageBuilder<T> |
setSequenceSize(java.lang.Integer sequenceSize) |
static <T> MessageBuilder<T> |
withPayload(T payload)
Create a builder for a new
Message instance with the provided payload. |
public static <T> MessageBuilder<T> fromMessage(Message<T> message)
Message
instance pre-populated with all of the headers copied from the
provided message. The payload of the provided Message will also be used as the payload for the new message.message
- the Message from which the payload and all headers will be copiedpublic static <T> MessageBuilder<T> withPayload(T payload)
Message
instance with the provided payload.payload
- the payload for the new messagepublic MessageBuilder<T> setHeader(java.lang.String headerName, java.lang.Object headerValue)
null
, the header will be removed.public MessageBuilder<T> setHeaderIfAbsent(java.lang.String headerName, java.lang.Object headerValue)
public MessageBuilder<T> removeHeaders(java.lang.String... headerPatterns)
headerPatterns
- public MessageBuilder<T> removeHeader(java.lang.String headerName)
public MessageBuilder<T> copyHeaders(java.util.Map<java.lang.String,?> headersToCopy)
copyHeadersIfAbsent(Map)
to avoid overwriting values. Note that the 'id' and 'timestamp' header values
will never be overwritten.MessageHeaders.ID
,
MessageHeaders.TIMESTAMP
public MessageBuilder<T> copyHeadersIfAbsent(java.util.Map<java.lang.String,?> headersToCopy)
public MessageBuilder<T> setExpirationDate(java.lang.Long expirationDate)
public MessageBuilder<T> setExpirationDate(java.util.Date expirationDate)
public MessageBuilder<T> setCorrelationId(java.lang.Object correlationId)
public MessageBuilder<T> pushSequenceDetails(java.lang.Object correlationId, int sequenceNumber, int sequenceSize)
public MessageBuilder<T> popSequenceDetails()
public MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)
public MessageBuilder<T> setReplyChannelName(java.lang.String replyChannelName)
public MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)
public MessageBuilder<T> setErrorChannelName(java.lang.String errorChannelName)
public MessageBuilder<T> setSequenceNumber(java.lang.Integer sequenceNumber)
public MessageBuilder<T> setSequenceSize(java.lang.Integer sequenceSize)
public MessageBuilder<T> setPriority(java.lang.Integer priority)