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

ObjectToJsonTransformer and DefaultJmsHeaderMapper violate JMS spec by default with content-type header

    Details

      Description

      Since the 2.2 release, ObjectToJsonTransformer adds content-type="application/json" message header by default and does not provide a way to disable/exclude the header.

      This is incompatible with DefaultJmsHeaderMapper because (1) it attempts to set non-standard JMS headers as object properties on the javax.jms.Message in the fromHeaders(MessageHeaders, javax.jms.Message) method and (2) the property name 'content-type' is not a valid Java identifier, violating sections 3.5.1 and 3.8.1.1 of the JMS spec.

      This results in unnecessary exception handling in DefaultJmsHeaderMapper and a WARN log statement for each message. In a high-throughput system, this can easily lead to excessive logging and wasted resources.

      Current workarounds include:

      1. Provide a custom header-mapper to each JMS outbound-channel-adapter or outbound-gateway in order to ignore or rewrite header names that are not valid Java identifiers
      2. Include a custom bean in flows/chains after each object-to-json-transformer to explicitly remove the 'content-type' header
      3. Configure log level for org.springframework.integration.jms.DefaultJmsHeaderMapper to ERROR

      Potential solutions:

      1. Modify DefaultJmsHeaderMapper logic to ignore or rewrite (e.g. convert to camelCase) header names that are not valid Java identifiers, os possibly just handle 'content-type' exclusively
      2. Provide a way to disable/exclude the 'content-type' header in object-to-json-transformer (as suggested by original PR for INT-2453)
      3. Change the log statement in DefaultJmsHeaderMapper (line 140) from WARN to DEBUG

        Attachments

          Activity

            People

            • Assignee:
              grussell Gary Russell
              Reporter:
              andrew.goode Andrew Goode
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 1h
                1h