Is it possible to pass JSON object to the RabbitMQ queue using java application?

Karthikeyan Velmurugan picture Karthikeyan Velmurugan · Dec 15, 2015 · Viewed 8.3k times · Source

I want to pass JSON object to the RabbitMQ queue.

In the below code, I am using obj.toJSONString().getBytes() for converting Json object in to string, Is it possible to pass JSON object in the queue instead passing as string.

Answer

Faariz Mohammed picture Faariz Mohammed · Dec 15, 2015

We can only send the data as bytes to a rabbitmq queue. So we have to convert the json object into string. In your code snippet, you have done by using the code - obj.toJSONString().getBytes(). This is the correct approach.