INT-4096: Allow Configuration of ReadOnly Headers
JIRA: https://jira.spring.io/browse/INT-4096 * Introduce `spring.integration.readOnly.headers` Integration property * Introduce `IntegrationMessageHeaderAccessor.setReadOnlyHeaders()` and use it from the overridden `IntegrationMessageHeaderAccessor.isReadOnly()` * Add `DefaultMessageBuilderFactory.setReadOnlyHeaders()` and delegate the value to the new `MessageBuilder.readOnlyHeaders()` * Modify `spring.integration.properties` for the `contentType` as a `readOnly` header for testing * Ensure that provided logic works via an appropriate modification to the `ObjectToJsonTransformerParserTests` Increase receive timeouts in the `OutboundGatewayFunctionTests` Fix `FileInboundTransactionTests` for slow `WatchService` issue on Linux/OS X Also redo the `tmp` dir logic to the `TemporaryFolder` `@ClassRule` Fix unused `import` in the `FileInboundTransactionTests` Polishing Conflicts: spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationProperties.java spring-integration-core/src/main/resources/META-INF/spring.integration.default.properties Some polishing and documentation Localize `readOnly.headers` customization only in the `ObjectToJsonTransformerParserTests-context.xml` Otherwise ti might affect many other tests and the search for the reason of failure would be enough complicated Doc Polish
This commit is contained in:
committed by
Gary Russell
parent
450ac7f18d
commit
dbcebebf38
@@ -205,6 +205,7 @@ spring.integration.channels.maxUnicastSubscribers=0x7fffffff <2>
|
||||
spring.integration.channels.maxBroadcastSubscribers=0x7fffffff <3>
|
||||
spring.integration.taskScheduler.poolSize=10 <4>
|
||||
spring.integration.messagingTemplate.throwExceptionOnLateReply=false <5>
|
||||
spring.integration.readOnly.headers= <6>
|
||||
----
|
||||
|
||||
<1> When true, `input-channel` s will be automatically declared as `DirectChannel` s when not explicitly found in the
|
||||
@@ -223,6 +224,11 @@ This can be overridden on individual channels with the `max-subscribers` attribu
|
||||
<5> When `true`, messages that arrive at a gateway reply channel will throw an exception, when the gateway is not
|
||||
expecting a reply - because the sending thread has timed out, or already received a reply.
|
||||
|
||||
<6> A comma-separated list of message header names which should not be populated into `Message` s during a header copying operation.
|
||||
The list is used by the `DefaultMessageBuilderFactory` bean and propagated to the `IntegrationMessageHeaderAccessor` instances (see <<message-header-accessor>>), used to build messages via `MessageBuilder` (see <<message-builder>>).
|
||||
By default only `MessageHeaders.ID` and `MessageHeaders.TIMESTAMP` are not copied during message building.
|
||||
_Since version 4.3.2_
|
||||
|
||||
These properties can be overridden by adding a file `/META-INF/spring.integration.properties` to the classpath.
|
||||
It is not necessary to provide all the properties, just those that you want to override.
|
||||
|
||||
|
||||
@@ -461,3 +461,8 @@ assertEquals(2, lessImportantMessage.getHeaders().getPriority());
|
||||
|
||||
The `priority` header is only considered when using a `PriorityChannel` (as described in the next chapter).
|
||||
It is defined as _java.lang.Integer_.
|
||||
|
||||
Since _version 4.3.2_, the `MessageBuilder` provides the `readOnlyHeaders(String... readOnlyHeaders)` API to customize a list of headers which should not be copied from an upstream `Message`.
|
||||
Just the `MessageHeaders.ID` and `MessageHeaders.TIMESTAMP` are read only by default.
|
||||
The global `spring.integration.readOnly.headers` property (see <<global-properties>>) is provided to customize `DefaultMessageBuilderFactory` for Framework components.
|
||||
This can be useful when you would like do not populate some out-of-the-box headers, like `contentType` by the `ObjectToJsonTransformer` (see <<json-transformers>>).
|
||||
|
||||
@@ -241,6 +241,7 @@ public StreamTransformer streamToString() {
|
||||
}
|
||||
----
|
||||
|
||||
[[json-transformers]]
|
||||
====== JSON Transformers
|
||||
|
||||
_Object to JSON_ and _JSON to Object_ transformers are provided.
|
||||
|
||||
@@ -37,3 +37,8 @@ See <<imap-format-important, the note in the Mail-Receiving Channel Adapter Sect
|
||||
==== (S)FTP Changes
|
||||
|
||||
The inbound channel adapters now have a property `max-fetch-size` which is used to limit the number of files fetched during a poll when there are no files currently in the local directory.
|
||||
|
||||
==== Integration Properties
|
||||
|
||||
Since _version 4.3.2_ a new `spring.integration.readOnly.headers` global property has been added to customize the list of headers which should not be copied to a newly created `Message` by the `MessageBuilder`.
|
||||
See <<global-properties>> for more information.
|
||||
|
||||
Reference in New Issue
Block a user