The Strong Programmer
The Strong Programmer

Reputation: 677

Spring rabbit message consumption, payload wrong format

I am consuming messages from a queue in rabbitmq like that

 @RabbitListener(queues = "#{'${rabbitmq.queues}'.split(',')}" )
public void processOrder(@Payload String data, @Header(AmqpHeaders.CONSUMER_QUEUE) String queue) {

The data I am printing in my logger seems to be bytes, it is printing values like that: 116,104,114,116,104,114,116,104,114 What am I supposed to do and how please? Deserialization?

Upvotes: 0

Views: 4285

Answers (1)

Gary Russell
Gary Russell

Reputation: 174574

The default SimpleMessageConverter can only handle String and serialized Java objects. Any content type it doesn't understand is returned as a byte[].

The content_type for a String should be text/plain.

What is the content of your message? Does the message have a content_type property? If so, what value?

If it's JSON (and application/json) you need a Jackson2JsonMessageConverter, but I see you expecting String, so I suspect it's just the missing content_type property.

Upvotes: 4

Related Questions