Class MutableMessageBuilder<T>
java.lang.Object
org.springframework.integration.support.AbstractIntegrationMessageBuilder<T>
org.springframework.integration.support.MutableMessageBuilder<T>
- Type Parameters:
- T- the payload type.
Specialized message builder that can be used within a component to avoid the overhead
 of having to build multiple messages for mutations within that component.
 
IMPORTANT: Mutable messages may share state (such as message headers); such messages should never be exposed to other components or undesirable side-effects may result.
It is generally recommended that messages transferred between components should always be immutable unless great care is taken with their use.
- Since:
- 4.0
- Author:
- Gary Russell, Artem Bilan
- 
Method SummaryModifier and TypeMethodDescriptionbuild()copyHeaders(Map<String, ?> headersToCopy) Copy the name-value pairs from the provided Map.copyHeadersIfAbsent(Map<String, ?> headersToCopy) Copy the name-value pairs from the provided Map.static <T> MutableMessageBuilder<T>fromMessage(Message<T> message) Create a builder for a newMessageinstance pre-populated with all of the headers copied from the provided message.protected Object<V> Vprotected Objectprotected ObjectremoveHeader(String headerName) Remove the value for the given header name.removeHeaders(String... headerPatterns) Removes all headers provided via array of 'headerPatterns'.Set the value for the given header name.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.static <T> MutableMessageBuilder<T>withPayload(T payload) Create a builder for a newMessageinstance with the provided payload.static <T> MutableMessageBuilder<T>withPayload(T payload, boolean generateHeaders) Create a builder for a newMessageinstance with the provided payload.Methods inherited from class org.springframework.integration.support.AbstractIntegrationMessageBuilderfilterAndCopyHeadersIfAbsent, popSequenceDetails, pushSequenceDetails, setCorrelationId, setErrorChannel, setErrorChannelName, setExpirationDate, setExpirationDate, setPriority, setReplyChannel, setReplyChannelName, setSequenceNumber, setSequenceSize
- 
Method Details- 
getPayload- Specified by:
- getPayloadin class- AbstractIntegrationMessageBuilder<T>
 
- 
getHeaders- Specified by:
- getHeadersin class- AbstractIntegrationMessageBuilder<T>
 
- 
getHeader- Specified by:
- getHeaderin class- AbstractIntegrationMessageBuilder<T>
 
- 
withPayloadCreate a builder for a newMessageinstance with the provided payload.- Type Parameters:
- T- The type of the payload.
- Parameters:
- payload- the payload for the new message
- Returns:
- A MutableMessageBuilder.
 
- 
withPayloadCreate a builder for a newMessageinstance with the provided payload. ThegenerateHeadersflag allows to disableMessageHeaders.IDandMessageHeaders.TIMESTAMPheaders generation.- Type Parameters:
- T- The type of the payload.
- Parameters:
- payload- the payload for the new message
- generateHeaders- whether generate- MessageHeaders.IDand- MessageHeaders.TIMESTAMPheaders
- Returns:
- A MutableMessageBuilder.
- Since:
- 5.0
 
- 
fromMessageCreate a builder for a newMessageinstance 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.- Type Parameters:
- T- The type of the payload.
- Parameters:
- message- the Message from which the payload and all headers will be copied
- Returns:
- A MutableMessageBuilder.
 
- 
setHeaderpublic AbstractIntegrationMessageBuilder<T> setHeader(String headerName, @Nullable Object headerValue) Description copied from class:AbstractIntegrationMessageBuilderSet the value for the given header name. If the provided value isnull, the header will be removed.- Specified by:
- setHeaderin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- headerValue- The header value.
- Returns:
- this.
 
- 
setHeaderIfAbsentpublic AbstractIntegrationMessageBuilder<T> setHeaderIfAbsent(String headerName, Object headerValue) Description copied from class:AbstractIntegrationMessageBuilderSet the value for the given header name only if the header name is not already associated with a value.- Specified by:
- setHeaderIfAbsentin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- headerValue- The header value.
- Returns:
- this.
 
- 
removeHeadersDescription copied from class:AbstractIntegrationMessageBuilderRemoves all headers provided via array of 'headerPatterns'. As the name suggests the array may contain simple matching patterns for header names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy".- Specified by:
- removeHeadersin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerPatterns- The header patterns.
- Returns:
- this.
 
- 
removeHeaderDescription copied from class:AbstractIntegrationMessageBuilderRemove the value for the given header name.- Specified by:
- removeHeaderin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- Returns:
- this.
 
- 
copyHeadersDescription copied from class:AbstractIntegrationMessageBuilderCopy the name-value pairs from the provided Map. This operation will overwrite any existing values. Use {AbstractIntegrationMessageBuilder.copyHeadersIfAbsent(Map)to avoid overwriting values. Note that the 'id' and 'timestamp' header values will never be overwritten.- Specified by:
- copyHeadersin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headersToCopy- The headers to copy.
- Returns:
- this.
- See Also:
 
- 
copyHeadersIfAbsentpublic AbstractIntegrationMessageBuilder<T> copyHeadersIfAbsent(@Nullable Map<String, ?> headersToCopy) Description copied from class:AbstractIntegrationMessageBuilderCopy the name-value pairs from the provided Map. This operation will not overwrite any existing values.- Specified by:
- copyHeadersIfAbsentin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headersToCopy- The headers to copy.
- Returns:
- this.
 
- 
getSequenceDetails- Specified by:
- getSequenceDetailsin class- AbstractIntegrationMessageBuilder<T>
 
- 
getCorrelationId- Specified by:
- getCorrelationIdin class- AbstractIntegrationMessageBuilder<T>
 
- 
getSequenceNumber- Specified by:
- getSequenceNumberin class- AbstractIntegrationMessageBuilder<T>
 
- 
getSequenceSize- Specified by:
- getSequenceSizein class- AbstractIntegrationMessageBuilder<T>
 
- 
build- Specified by:
- buildin class- AbstractIntegrationMessageBuilder<T>
 
 
-