public final class MessageBuilder<T> extends AbstractIntegrationMessageBuilder<T>
GenericMessage
s.
Named MessageBuilder instead of DefaultMessageBuilder for backwards
compatibility.Modifier and Type | Method and Description |
---|---|
Message<T> |
build() |
MessageBuilder<T> |
copyHeaders(Map<String,?> headersToCopy)
Copy the name-value pairs from the provided Map.
|
MessageBuilder<T> |
copyHeadersIfAbsent(Map<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. |
protected Object |
getCorrelationId() |
protected List<List<Object>> |
getSequenceDetails() |
protected Object |
getSequenceNumber() |
protected Object |
getSequenceSize() |
MessageBuilder<T> |
popSequenceDetails() |
MessageBuilder<T> |
pushSequenceDetails(Object correlationId,
int sequenceNumber,
int sequenceSize) |
MessageBuilder<T> |
removeHeader(String headerName)
Remove the value for the given header name.
|
MessageBuilder<T> |
removeHeaders(String... headerPatterns)
Removes all headers provided via array of 'headerPatterns'.
|
MessageBuilder<T> |
setCorrelationId(Object correlationId) |
MessageBuilder<T> |
setErrorChannel(MessageChannel errorChannel) |
MessageBuilder<T> |
setErrorChannelName(String errorChannelName) |
MessageBuilder<T> |
setExpirationDate(Date expirationDate) |
MessageBuilder<T> |
setExpirationDate(Long expirationDate) |
MessageBuilder<T> |
setHeader(String headerName,
Object headerValue)
Set the value for the given header name.
|
MessageBuilder<T> |
setHeaderIfAbsent(String headerName,
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(Integer priority) |
MessageBuilder<T> |
setReplyChannel(MessageChannel replyChannel) |
MessageBuilder<T> |
setReplyChannelName(String replyChannelName) |
MessageBuilder<T> |
setSequenceNumber(Integer sequenceNumber) |
MessageBuilder<T> |
setSequenceSize(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.T
- The type of the payload.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.T
- The type of the payload.payload
- the payload for the new messagepublic MessageBuilder<T> setHeader(String headerName, Object headerValue)
null
, the header will be removed.setHeader
in class AbstractIntegrationMessageBuilder<T>
headerName
- The header name.headerValue
- The header value.public MessageBuilder<T> setHeaderIfAbsent(String headerName, Object headerValue)
setHeaderIfAbsent
in class AbstractIntegrationMessageBuilder<T>
headerName
- The header name.headerValue
- The header value.public MessageBuilder<T> removeHeaders(String... headerPatterns)
removeHeaders
in class AbstractIntegrationMessageBuilder<T>
headerPatterns
- The header patterns.public MessageBuilder<T> removeHeader(String headerName)
removeHeader
in class AbstractIntegrationMessageBuilder<T>
headerName
- The header name.public MessageBuilder<T> copyHeaders(Map<String,?> headersToCopy)
copyHeadersIfAbsent(Map)
to avoid overwriting values. Note that the 'id' and 'timestamp' header values
will never be overwritten.copyHeaders
in class AbstractIntegrationMessageBuilder<T>
headersToCopy
- The headers to copy.MessageHeaders.ID
,
MessageHeaders.TIMESTAMP
public MessageBuilder<T> copyHeadersIfAbsent(Map<String,?> headersToCopy)
copyHeadersIfAbsent
in class AbstractIntegrationMessageBuilder<T>
headersToCopy
- The headers to copy.protected List<List<Object>> getSequenceDetails()
getSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
protected Object getCorrelationId()
getCorrelationId
in class AbstractIntegrationMessageBuilder<T>
protected Object getSequenceNumber()
getSequenceNumber
in class AbstractIntegrationMessageBuilder<T>
protected Object getSequenceSize()
getSequenceSize
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> pushSequenceDetails(Object correlationId, int sequenceNumber, int sequenceSize)
pushSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> popSequenceDetails()
popSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setExpirationDate(Long expirationDate)
setExpirationDate
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setExpirationDate(Date expirationDate)
setExpirationDate
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setCorrelationId(Object correlationId)
setCorrelationId
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)
setReplyChannel
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setReplyChannelName(String replyChannelName)
setReplyChannelName
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)
setErrorChannel
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setErrorChannelName(String errorChannelName)
setErrorChannelName
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setSequenceNumber(Integer sequenceNumber)
setSequenceNumber
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setSequenceSize(Integer sequenceSize)
setSequenceSize
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setPriority(Integer priority)
setPriority
in class AbstractIntegrationMessageBuilder<T>
public Message<T> build()
build
in class AbstractIntegrationMessageBuilder<T>