withHeader
Adds a key-value pair to the message header and returns the message for method chaining.
This provides a fluent API for setting header metadata. If the message is read-only, this operation may throw an exception or be ignored.
Return
This message instance (cast to SOURCE type) to support method chaining
Parameters
The header key to set (must not be null)
The header value to associate with the key (must not be null)
Throws
if the message is read-only and header modifications are not allowed
Adds all key-value pairs from the provided map to the message header and returns the message for method chaining.
This provides a fluent API for bulk setting header metadata. If the message is read-only, this operation may throw an exception or be ignored.
Return
This message instance (cast to SOURCE type) to support method chaining
Parameters
A map containing key-value pairs to add to the header (must not be null)
Throws
if the message is read-only and header modifications are not allowed