withHeader

open fun withHeader(key: String, value: String): SOURCE

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

key

The header key to set (must not be null)

value

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


open fun withHeader(additionalSource: Map<String, String>): SOURCE

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

additionalSource

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