AMQP-618: Add contentType note into JSON Docs

JIRA: https://jira.spring.io/browse/AMQP-618

Also, in the `Jackson2JsonMessageConverter`, wrap `log.warn()` with String concatenation into `log.isWarnEnabled()`
This commit is contained in:
Artem Bilan
2016-07-15 13:59:09 -04:00
committed by Gary Russell
parent a8efa73b30
commit 999090f63d
2 changed files with 8 additions and 2 deletions

View File

@@ -159,8 +159,10 @@ public class Jackson2JsonMessageConverter extends AbstractJsonMessageConverter {
}
}
else {
log.warn("Could not convert incoming message with content-type ["
+ contentType + "]");
if (log.isWarnEnabled()) {
log.warn("Could not convert incoming message with content-type ["
+ contentType + "]");
}
}
}
if (content == null) {

View File

@@ -2268,6 +2268,10 @@ The property is actually on the converter's `DefaultJackson2JavaTypeMapper` but
for convenience.
If you inject a custom type mapper, you should set the property on the mapper instead.
NOTE: When converting from the `Message`, an incoming `MessageProperties.getContentType()` must be JSON-compliant (the logic `contentType.contains("json")` is used).
Otherwise, a `WARN` log message `Could not convert incoming message with content-type [...]`, is emitted and `message.getBody()` is returned as is - as a `byte[]``.
So, to meet the `Jackson2JsonMessageConverter` requirements on the consumer side, the producer must add the `contentType` message property, e.g. as `application/json`, `text/x-json` or simply use the `Jackson2JsonMessageConverter`, which will set the header automatically.
[source, java]
----
@RabbitListener