GH-2268: Add RedisHeaders.MESSAGE_SOURCE header

Resolves: /spring-projects/spring-integration#2268

* To indicate the source the Redis message in the `RedisInboundChannelAdapter`
populate the `RedisHeaders.MESSAGE_SOURCE` header to the messages to produce
* Fix the `SimpleMessageConverter` to populate the provided `MessageHeaders`
to the message to produce

* Add `toMessage(T object, @Nullable Map<String, Object> headers)`
to the `InboundMessageMapper` to propagate additional header
to the message to create
* Rework all the out-of-the-box `InboundMessageMapper` implementations
to properly propagate additional headers via `toMessage()`
from the `SimpleMessageConverter`
* Provide optimizations in the `InboundMessageMapper` implementations
do not re-create messages
* Refactor `MutableMessage.toString()` to align with the `GenericMessage`

* Add more `@Nullable` to method arguments
* Increase latch wait timeout in the `EndpointParserTests`
* Address `redis.adoc` PR comment
This commit is contained in:
Artem Bilan
2017-11-07 13:25:33 -05:00
committed by Gary Russell
parent 70c166fbfd
commit 7ca20e53f7
23 changed files with 249 additions and 104 deletions

View File

@@ -103,8 +103,8 @@ Instead those Messages are passed through Redis allowing you to rely on its supp
[[redis-inbound-channel-adapter]]
==== Redis Inbound Channel Adapter
The Redis-based Inbound Channel Adapter adapts incoming Redis messages into Spring Integration Messages in the same way as other inbound adapters.
It receives platform-specific messages (Redis in this case) and converts them to Spring Integration Messages using a `MessageConverter` strategy.
The Redis-based Inbound Channel Adapter (`RedisInboundChannelAdapter`) adapts incoming Redis messages into Spring Messages in the same way as other inbound adapters.
It receives platform-specific messages (Redis in this case) and converts them to Spring Messages using a `MessageConverter` strategy.
[source,xml]
----
<int-redis:inbound-channel-adapter id="redisAdapter"
@@ -141,6 +141,8 @@ The `serializer` attribute of the `<int-redis:inbound-channel-adapter>` can be s
In this case the raw `byte[]` bodies of Redis Messages are provided as the message payloads.
Since _version 5.0_, an `Executor` instance can be provided to the Inbound Adapter via the `task-executor` attribute of the `<int-redis:inbound-channel-adapter>`.
Also the received Spring Integration Messages have now `RedisHeaders.MESSAGE_SOURCE` header to indicate the source of the published message - topic or pattern.
This can be used downstream for routing logic.
[[redis-outbound-channel-adapter]]
==== Redis Outbound Channel Adapter

View File

@@ -273,6 +273,7 @@ The `zsetIncrementExpression` can now be configured on the `RedisStoreWritingMes
In addition this property has been changed from `true` to `false` since `INCR` option on `ZADD` Redis command is optional.
The `RedisInboundChannelAdapter` can now be supplied with an `Executor` for executing Redis listener invokers.
In addition the received messages now contains a `RedisHeaders.MESSAGE_SOURCE` header to indicate the source of the message - topic or pattern.
See <<redis>> for more information.