I tried @OutHeaders outHeaderBound – I inspected in debug, I could see it is null. If I initialize a new hashtable/map for outHeaderBound, the headers key/value were not propagated to downstream queues.
e.g code snippet:
public void populateCorrelationId(@Body String body, @Headers Map<String, Object> headers,
@OutHeaders Map<String, Object> outHeaderBound, Exchange exchange) {
Map<String, Object> outHeader = exchange.getOut().getHeaders();
String msgId = (String) headers.get(msgIdKey);
String currentCorrId = (String) headers.get(correlationIdKey);
I tried outHeader = exchange.getOut().getHeaders(), I got an empty map, and headers that I put in outHeader got propagated.
I expect that @OutHeader and exchange.getOut.getHeader() both must give an empty map rather then one giving null.
Is this a bug? or intended for some functionality.
Oops I could not submit screenshot image of debug session.
See this FAQ – http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html
And see the javadoc of the getOut() method on Exchange, then you would see that getOut will lazy create empty message if it was null. And therefore one is null and the other is an empty map, as the latter is due, getOut created an empty message.
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html