[INT-2454] docs don't mention the need to add amqp_ prefix to headers in order to have DefaultAmqpHeaderMapper add it to the message Created: 23/Feb/12  Updated: 03/Jul/12  Resolved: 25/Jun/12

Status: Closed
Project: Spring Integration
Component/s: Documentation
Affects Version/s: 2.1 GA
Fix Version/s: 2.2 M3 Sprint 4, 2.2 M3

Type: Bug Priority: Major
Reporter: Kyle Smith Assignee: Gunnar Hillert
Resolution: Complete Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 0.25d
Original Estimate: 0.25d
Environment:

Mac OS X 10.7.3
Java 1.6.0_29
Spring AMQP 1.0.0.RELEASE
Spring Integration 2.1.0.RELEASE



 Description   

I was attempting to have a header enricher add a content type header to a message that was subsequently being handled by an outbound AMQP channel adapter and found that various combinations of contentType and content-type for the header name weren't working.

After digging through DefaultAmqpHeaderMapper and AmqpHeaders I realized that it needs an 'amqp_' prefix in order for the header mapper to automatically copy it. It would be good for this to be mentioned in the docs, or a better way of handling standard AMQP headers to be developed.

Here is a snippet illustrating the final config that worked:

<int:chain input-channel="input" output-channel="output">
    <int:object-to-json-transformer />
    <int:header-enricher>
        <int:header name="amqp_contentType" value="application/json" overwrite="true" />
    </int:header-enricher>
</int:chain>



 Comments   
Comment by Gary Russell [ 23/Feb/12 ]

One option to avoid these issues is to use a SpEL expression - it can get a little verbose with long package names, though...

<int:header name="#{T(org.springframework.integration.amqp.AmqpHeaders).CONTENT_TYPE}" value="application/json" overwrite="true" />

I agree it should be documented though (perhaps as well as showing this technique).

Comment by Mark Fisher [ 23/Feb/12 ]

Another (perhaps additional) nice feature would be an "amqp:header-enricher" element that simply provides common AMQP header names as sub-elements (like we do for mail, jms, etc.) Thoughts?

Comment by Gunnar Hillert [ 24/Jun/12 ]

Adding a dedicated (short) chapter specifically for AMQP Headers. There I am listing all available, automatically mapped AMQP Headers.

Comment by Gunnar Hillert [ 24/Jun/12 ]

Issued PR: https://github.com/SpringSource/spring-integration/pull/521

Generated at Tue Oct 17 16:57:21 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.