-
Notifications
You must be signed in to change notification settings - Fork 636
Wrong content type in reply message #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a Spring Integration issue, not Spring AMQP.
Your inbound gateway needs to be configured with the jackson converter (and remove the transformers). The gateway has a The outbound endpoints have a property /**
* When mapping headers for the outbound message, determine whether the headers are
* mapped before the message is converted, or afterwards. This only affects headers
* that might be added by the message converter. When false, the converter's headers
* win; when true, any headers added by the converter will be overridden (if the
* source message has a header that maps to those headers). You might wish to set this
* to true, for example, when using a
* {@link org.springframework.amqp.support.converter.SimpleMessageConverter} with a
* String payload that contains json; the converter will set the content type to
* {@code text/plain} which can be overridden to {@code application/json} by setting
* the {@link AmqpHeaders#CONTENT_TYPE} message header. Default: false.
* @param headersMappedLast true if headers are mapped after conversion.
* @since 5.0
*/
public void setHeadersMappedLast(boolean headersMappedLast) {
this.headersMappedLast = headersMappedLast;
} We should have a similar property for the reply handling in the inbound gateway. Moving this to Spring Integration. |
Issue moved to spring-projects/spring-integration #3089 via ZenHub |
Ignore my last comment (deleted) the converter goes on the gateway not the listener container. |
Thank you for your answer! Is it possible to create a Jackson2JsonMessageConverter that handles a specific type for a generic type: Say I have a type Container and I'd want to create a Jackson2JsonMessageConverter that handles instances of Container because I have a queue that contains only those? |
There are several ways to influence the types created by the Jackson converter.
Please don't use GitHub issues to ask questions; we prefer Stack Overflow (tagged with spring-amqp) because it makes it easier for others to find answers. |
Verisions: Spring AMQP 2.2.0, Spring 5.2.0
I have the following simple test:
I managed to make this work by overriding Jackson2JsonMessageConverter#fromMessage that sets the content type before processing. However, the content type in the RabbitMQ reply message is text/plain. Here's what the RabbitMQ firehose log shows:
Here's the Spring logs:
I feel like there's a problem here where the new MessageProperties have a contentType of text/plain. I don't see how to configure this since the toMessage method of Jackson2JsonMessageConverter cannot be overriden.
The text was updated successfully, but these errors were encountered: