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 184.108.40.206 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:
- 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
- Include a custom bean in flows/chains after each object-to-json-transformer to explicitly remove the 'content-type' header
- Configure log level for org.springframework.integration.jms.DefaultJmsHeaderMapper to ERROR
- 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
- Provide a way to disable/exclude the 'content-type' header in object-to-json-transformer (as suggested by original PR for INT-2453)
- Change the log statement in DefaultJmsHeaderMapper (line 140) from WARN to DEBUG