I have a usecase where a service consumes different RabbitMQ queues.
- On one of the queues there is JSON encoded data, where the content_type header is set to
application/json
- There is a second queue, where binary data is being consumed, content_type is
application/octet-stream
In the configuration there is a MessageConverter defined:
@Bean
public MessageConverter jsonMessageConverter(){
return new Jackson2JsonMessageConverter();
}
Consuming methods are declared like that:
@RabbitListener(queues = "rpc-device-cmd")
public byte[] rpcCommand(byte[] request) throws IOException, ConfigurationException { .... }
My issue is that Jackson2JsonMessageConverter complains about the application/octet-stream
header (
Could not convert incoming message with content-type application/octet-stream 'json' keyword missing.
) and even worse, it is encoding the byte[] response of the method above to JSON and base64.
Question:
How is it possible to make sure that the JSON converter does not touch my byte[] responses and ignores messages with a "non-json" content_type?