public final class MessageBuilder<T> extends AbstractIntegrationMessageBuilder<T>
GenericMessage
s.
Named MessageBuilder instead of DefaultMessageBuilder for backwards
compatibility.Modifier and Type | Method and Description |
---|---|
org.springframework.messaging.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(org.springframework.messaging.Message<T> message)
Create a builder for a new
Message instance pre-populated with all of the headers copied from the
provided message. |
protected java.lang.Object |
getCorrelationId() |
java.util.Map<java.lang.String,java.lang.Object> |
getHeaders() |
T |
getPayload() |
protected java.util.List<java.util.List<java.lang.Object>> |
getSequenceDetails() |
protected java.lang.Object |
getSequenceNumber() |
protected java.lang.Object |
getSequenceSize() |
MessageBuilder<T> |
popSequenceDetails() |
MessageBuilder<T> |
pushSequenceDetails(java.lang.Object correlationId,
int sequenceNumber,
int sequenceSize) |
MessageBuilder<T> |
readOnlyHeaders(java.lang.String... readOnlyHeaders)
Specify a list of headers which should be considered as read only
and prohibited from being populated in the message.
|
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(org.springframework.messaging.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(org.springframework.messaging.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 T getPayload()
getPayload
in class AbstractIntegrationMessageBuilder<T>
public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
getHeaders
in class AbstractIntegrationMessageBuilder<T>
public static <T> MessageBuilder<T> fromMessage(org.springframework.messaging.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(java.lang.String headerName, @Nullable java.lang.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(java.lang.String headerName, java.lang.Object headerValue)
setHeaderIfAbsent
in class AbstractIntegrationMessageBuilder<T>
headerName
- The header name.headerValue
- The header value.public MessageBuilder<T> removeHeaders(java.lang.String... headerPatterns)
removeHeaders
in class AbstractIntegrationMessageBuilder<T>
headerPatterns
- The header patterns.public MessageBuilder<T> removeHeader(java.lang.String headerName)
removeHeader
in class AbstractIntegrationMessageBuilder<T>
headerName
- The header name.public MessageBuilder<T> copyHeaders(@Nullable 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.copyHeaders
in class AbstractIntegrationMessageBuilder<T>
headersToCopy
- The headers to copy.MessageHeaders.ID
,
MessageHeaders.TIMESTAMP
public MessageBuilder<T> copyHeadersIfAbsent(@Nullable java.util.Map<java.lang.String,?> headersToCopy)
copyHeadersIfAbsent
in class AbstractIntegrationMessageBuilder<T>
headersToCopy
- The headers to copy.protected java.util.List<java.util.List<java.lang.Object>> getSequenceDetails()
getSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
protected java.lang.Object getCorrelationId()
getCorrelationId
in class AbstractIntegrationMessageBuilder<T>
protected java.lang.Object getSequenceNumber()
getSequenceNumber
in class AbstractIntegrationMessageBuilder<T>
protected java.lang.Object getSequenceSize()
getSequenceSize
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> pushSequenceDetails(java.lang.Object correlationId, int sequenceNumber, int sequenceSize)
pushSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> popSequenceDetails()
popSequenceDetails
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setExpirationDate(java.lang.Long expirationDate)
setExpirationDate
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setExpirationDate(java.util.Date expirationDate)
setExpirationDate
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setCorrelationId(java.lang.Object correlationId)
setCorrelationId
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setReplyChannel(org.springframework.messaging.MessageChannel replyChannel)
setReplyChannel
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setReplyChannelName(java.lang.String replyChannelName)
setReplyChannelName
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
setErrorChannel
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setErrorChannelName(java.lang.String errorChannelName)
setErrorChannelName
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setSequenceNumber(java.lang.Integer sequenceNumber)
setSequenceNumber
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setSequenceSize(java.lang.Integer sequenceSize)
setSequenceSize
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> setPriority(java.lang.Integer priority)
setPriority
in class AbstractIntegrationMessageBuilder<T>
public MessageBuilder<T> readOnlyHeaders(java.lang.String... readOnlyHeaders)
readOnlyHeaders
- the list of headers for readOnly
mode.
Defaults to MessageHeaders.ID
and MessageHeaders.TIMESTAMP
.MessageBuilder
IntegrationMessageHeaderAccessor.isReadOnly(String)
public org.springframework.messaging.Message<T> build()
build
in class AbstractIntegrationMessageBuilder<T>