Converting Message from RabbitMQ into string/json
message.getBody()
returns a byte[]
Try:
byte[] body = message.getBody();
System.out.println(new String(body));
If you want to parse to a JSONObject, the best way is add the RabbitMQ message to a StringBuilder in String format. Then parse the StringBuilder into a JSONObject, by using any of the conversion utils.
For e.g.:
StringBuilder sb = new StringBuilder();
sb.append(publisher.toString());
payload = (JSONObject)jsonParser.parse(sb.toString());