Question

I am using redis as my message store for spring-xd distributed env.

I am setting the message header as below,

oufinalTreeMapsg1 = MessageBuilder.withPayload(treeMap).setHeader("columnNames", columnNames).build();

while checking the message received in the processor it shows only id and timestamp

Headers while sending

[Headers={columnNames=abc,def, id=74acf995-ec39-0e1c-a426-c9e27b1d47d6, timestamp=1406784568493}]

Headers received

[Headers={id=aed8dc5b-5b24-d444-7583-c2da7a21d31c, timestamp=1406784568495}]

here the id and the timestamp are different but payload is same.

Please help me on resolving this issue,

Thanks in advance, -Suyodha

Was it helpful?

Solution

The Redis message bus doesn't support passing custom headers by default; you can, however, add custom headers to those passed by adding a comma-delimited list in a third <constructor-arg/> in redis-bus.xml (in the xd-dirt jar). For example...

<constructor-arg value="foo, bar" />

...will pass headers foo and bar.

However, even then, only simple String values can be passed.

In Spring Integration (used by the bus), messages are immutable; when they are transported over some medium (e.g. the redis message bus) a new message is created with the content but those headers (id and timestamp) will change.

The RabbitMessageBus passes all custom headers by default.

UPDATE

Redis and kafka have no concept of message headers or properties.

The redis and kafka message bus implementations now support properties in servers.yml to add custom headers to those that are transported over the bus.

By default, only some system level headers are transported.

See headers: in servers.yml in Redis (and Kafka) under Application Configuration.

comma-delimited list of additional (string-valued) header names to transport

Note that the this (for redis) incorrectly says that these must be string-valued. This was originally the case, but now any object that can be converted to/from json can be in a header value.

In addition, kafka has a raw mode, in which case no headers are conveyed over the bus at all; this might be desired for performance reasons but things (like message type conversion) can not be supported in this mode because the framework can't determine the type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top