INT-4284: INFO about overriding readOnly headers

JIRA: https://jira.spring.io/browse/INT-4284

Add `INFO` into the `MessageBuilder#copyHeadersIfAbsent()` when end-user
tries to populate headers which are `readOnly`

We can't throw exception on the matter since can modify `readOnlyHeaders`
and that would force end-user to add `header-filter` logic to the application.

* Document `readOnly` headers in the `message.adoc`

**Cherry-pick 4.3.x**
This commit is contained in:
Artem Bilan
2017-06-02 12:41:56 -04:00
committed by Gary Russell
parent 2c7bf9271c
commit 33e9ce912f
4 changed files with 67 additions and 2 deletions

View File

@@ -370,6 +370,13 @@ If the strategy is the same, but parameterized, the strategy in the first contex
In addition to the default strategy, two additional `IdGenerators` are provided; `org.springframework.util.JdkIdGenerator` uses the previous `UUID.randomUUID()` mechanism; `o.s.i.support.IdGenerators.SimpleIncrementingIdGenerator` can be used in cases where a UUID is not really needed and a simple incrementing value is sufficient.
[[read-only-headers]]
===== Read-only Headers
The `MessageHeaders.ID` and `MessageHeaders.TIMESTAMP` are read-only headers and the cannot be overridden.
With the `spring.integration.readOnly.headers` global property (see <<global-properties>>) you can specify any header names which become read-only.
When you try to build a new message using `MessageBuilder`, this kind of headers are ignored and particular `INFO` message is emitted to logs.
[[message-implementations]]
==== Message Implementations