Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-2454

docs don't mention the need to add amqp_ prefix to headers in order to have DefaultAmqpHeaderMapper add it to the message

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 2.1 GA
    • Fix Version/s: 2.2 M3 Sprint 4, 2.2 M3
    • Component/s: Documentation
    • Labels:
      None
    • 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>

        Activity

        kylesm Kyle Smith created issue -
        Hide
        grussell Gary Russell added a comment -

        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).

        Show
        grussell Gary Russell added a comment - 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).
        Hide
        mark.fisher Mark Fisher added a comment -

        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?

        Show
        mark.fisher Mark Fisher added a comment - 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?
        hillert Gunnar Hillert made changes -
        Field Original Value New Value
        Priority Minor [ 4 ] Major [ 3 ]
        Fix Version/s 2.2 Backlog [ 12807 ]
        hillert Gunnar Hillert made changes -
        Remaining Estimate 0.25d [ 7200 ]
        Fix Version/s 2.2 Backlog [ 12807 ]
        Fix Version/s 2.2 M3 Sprint 3 [ 13004 ]
        Original Estimate 0.25d [ 7200 ]
        hillert Gunnar Hillert made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        hillert Gunnar Hillert added a comment -

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

        Show
        hillert Gunnar Hillert added a comment - Adding a dedicated (short) chapter specifically for AMQP Headers. There I am listing all available, automatically mapped AMQP Headers.
        hillert Gunnar Hillert logged work - 24/Jun/12 7:25 PM
        • Time Spent:
          0.25d
           
          <No comment>
        Show
        hillert Gunnar Hillert added a comment - Issued PR: https://github.com/SpringSource/spring-integration/pull/521
        hillert Gunnar Hillert made changes -
        Remaining Estimate 0.25d [ 7200 ] 0d [ 0 ]
        Time Spent 0.25d [ 7200 ]
        Worklog Id 29011 [ 29011 ]
        grussell Gary Russell made changes -
        Fix Version/s 2.2 M3 Sprint 4 [ 13014 ]
        Fix Version/s 2.2 M3 Sprint 3 [ 13004 ]
        grussell Gary Russell made changes -
        Resolution Complete [ 8 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        grussell Gary Russell made changes -
        Fix Version/s 2.2 M3 [ 13000 ]
        grussell Gary Russell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        121d 1h 23m 1 Gunnar Hillert 23/Jun/12 1:28 PM
        In Progress In Progress Resolved Resolved
        2d 35m 1 Gary Russell 25/Jun/12 2:03 PM
        Resolved Resolved Closed Closed
        7d 17h 19m 1 Gary Russell 03/Jul/12 7:23 AM

          People

          • Assignee:
            hillert Gunnar Hillert
            Reporter:
            kylesm Kyle Smith
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25d
              0.25d
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 0.25d
              0.25d