title: SimpleMessageListenerContainer: Consumer raised exception, processing can restart if processing supports it
body: <p>I have a Spring Boot application interfacing with a rabbitmq broker which manages to startup fine but I am getting a constant start/shutdown of the message consumer regardless of there being a message on the queue. Below is a copy of my application log and client class: </p>
  
  <blockquote>
    <p>2016-10-19 11:40:25,909 WARN  t:[SimpleAsyncTaskExecutor-106] SimpleMessageListenerContainer: Consumer raised exception, processing can restart if the connection factory supports it
    java.lang.NullPointerException: null
        at com.rabbitmq.client.impl.ChannelN.validateQueueNameLength(ChannelN.java:1232) ~[amqp-client-3.5.5.jar:na]
        at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:884) ~[amqp-client-3.5.5.jar:na]
        at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:61) ~[amqp-client-3.5.5.jar:na]
        at sun.reflect.GeneratedMethodAccessor334.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
        at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:666) ~[spring-rabbit-1.4.6.RELEASE.jar:na]
        at com.sun.proxy.$Proxy181.queueDeclarePassive(Unknown Source) ~[na:na]
        at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:533) ~[spring-rabbit-1.4.6.RELEASE.jar:na]
        at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:453) ~[spring-rabbit-1.4.6.RELEASE.jar:na]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1083) ~[spring-rabbit-1.4.6.RELEASE.jar:na]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
    2016-10-19 11:40:25,909 INFO  t:[SimpleAsyncTaskExecutor-106] SimpleMessageListenerContainer: Restarting Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), acknowledgeMode=AUTO local queue size=0
    2016-10-19 11:40:25,910 DEBUG t:[SimpleAsyncTaskExecutor-106] BlockingQueueConsumer: Closing Rabbit Channel: Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1)
    2016-10-19 11:40:25,910 DEBUG t:[SimpleAsyncTaskExecutor-106] CachingConnectionFactory: Closing cached Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1)
    2016-10-19 11:40:25,911 DEBUG t:[SimpleAsyncTaskExecutor-107] DefaultListableBeanFactory: Returning cached instance of singleton bean 'macRequestQueue'
    2016-10-19 11:40:25,911 DEBUG t:[SimpleAsyncTaskExecutor-107] BlockingQueueConsumer: Starting consumer Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
    2016-10-19 11:40:25,912 DEBUG t:[SimpleAsyncTaskExecutor-107] CachingConnectionFactory: Creating cached Rabbit Channel from AMQChannel(amqp://guest@127.0.0.1:5672/,1)
    2016-10-19 11:40:25,912 DEBUG t:[SimpleAsyncTaskExecutor-107] SimpleMessageListenerContainer: Recovering consumer in 5000 ms. </p>
  </blockquote>
  
  <p>Below is a copy of my client class:</p>
  
  <pre><code>public class RabbitClientConfiguration extends AbstractEMCRabbitConfiguration     {
  
  @Inject
  private JacksonConfiguration jacksonConfiguration;
  
  @Inject
  private MessagingConfiguration messagingConfiguration;
  
  //@Value("${data.core.pattern}")
  //private String coreDataRoutingKey;
  
  //@Inject
  //private ClientHandler clientHandler;
  
  @Override
  public void configureRabbitTemplate(RabbitTemplate rabbitTemplate) {
      rabbitTemplate.setRoutingKey(MAC_REQUEST_ROUTING_KEY);
  }
  
  @Bean
  public SimpleMessageListenerContainer messageListenerContainer(){
      SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
      container.setConnectionFactory(connectionFactory());
      container.setQueueNames(MAC_REQUEST_QUEUE_NAME);
      container.setMessageListener(messageListenerAdapter());
      container.setAcknowledgeMode(AcknowledgeMode.AUTO);
      return container;
  }
  
  @Bean
  MessageListenerAdapter messageListenerAdapter(){
      return new MessageListenerAdapter(clientHandler(jacksonConfiguration.objectMapper(),messagingConfiguration.macMessageHandler(messagingConfiguration.messagingFactory())),jsonMessageConverter());
      //return new MessageListenerAdapter(clientHandler,"receiveMessage");
  }
  
  @Bean
  ClientHandler clientHandler(ObjectMapper objectMapper, IMessageHandler macMessageHandler){
      ClientHandler clientHandler = new ClientHandler();
      clientHandler.setObjectMapper(objectMapper);
      clientHandler.setMacMessageHandler(macMessageHandler);
      return clientHandler;
  }
  
  
  @Bean
  public AmqpAdmin rabbitAdmin() { return new RabbitAdmin(connectionFactory());}
  
  }
  </code></pre>