title: Converting Message from RabbitMQ into string/json
body: <p>I am currently struggling hard with a fair simple problem. I want to receive a message from RabbitMQ and have that transformed into a string (or later a json object). But all I get is bytes.</p>
  
  <p>The <em>Message</em> object displays itself as a string that way</p>
  
  <pre><code>(Body:'{"cityId":644}'; ID:null; Content:application/json; Headers:{}; Exchange:; RoutingKey:pages.type.index; Reply:null; DeliveryMode:NON_PERSISTENT; DeliveryTag:1)
  </code></pre>
  
  <p>The configuration class (using spring)</p>
  
  <pre><code>@Configuration
  public class RabbitConfiguration {
  
      @Bean
      public CachingConnectionFactory connectionFactory() {
          CachingConnectionFactory connectionFactory = new CachingConnectionFactory("www.example.com");
          connectionFactory.setUsername("xxxx");
          connectionFactory.setPassword("xxxx");
          return connectionFactory;
      }
  
      @Bean
      public MessageConverter jsonMessageConverter(){
          JsonMessageConverter jsonMessageConverter = new JsonMessageConverter();
          return jsonMessageConverter;
      }
  
      @Bean
      public SimpleMessageListenerContainer messageListenerContainer(){
          SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
          container.setAutoStartup(false);
          container.setQueues(indexQueue());
          container.setConcurrentConsumers(1);
          container.setAcknowledgeMode(AcknowledgeMode.AUTO);
          container.setMessageListener(new MessageListenerAdapter(pageListener(), jsonMessageConverter()));
          return container;
      }
  
      @Bean
      public Queue indexQueue(){
          return new Queue("pages.type.index");
      }
  
      @Bean
      public MessageListener pageListener(){
          return new PageQueueListener();
      }
  
  }
  </code></pre>
  
  <p>and the message listener</p>
  
  <pre><code>public class PageQueueListener implements MessageListener {
  
      public void onMessage(Message message) {
          System.out.println(message);
          System.out.println(message.getBody());
      }
   }
  </code></pre>
  
  <p>my problem is, that the <em>getBody()</em> method displayes <em>[B@4dbb73b0</em> so nothing is ever converted. Neither to a string nor to a json object :(</p>
  
  <p>I feel stupid, but I cannot find a solution here</p>