11

I am getting the following exception repeatedly when I start my spring boot application with rabbitmq. The entire flow is working fine even with the below exceptions. is it to do with the auto-delete in by means ?

    08 Jul 2015 16:20:17,652 [ERROR] [SimpleAsyncTaskExecutor-2] SimpleMessageListenerContainer| Failed to check/redeclare auto-delete queue(s).
    java.util.concurrent.TimeoutException
        at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
        at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:111)
        at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)
        at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:367)
        at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:621)
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:665)
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:208)
        at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:444)
        at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)
        at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)
        at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)
        at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1035)
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1028)
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1004)
        at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:254)
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:963)
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$300(SimpleMessageListenerContainer.java:83)
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1081)
        at java.lang.Thread.run(Thread.java:745)

08 Jul 2015 16:52:47,148 [WARN ] [SimpleAsyncTaskExecutor-1] SimpleMessageListenerContainer| Consumer raised exception, processing can restart if the connection factory supports it
java.util.concurrent.TimeoutException
    at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
    at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:111)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:367)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:621)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:665)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:208)
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:444)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)
    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:434)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1083)
    at java.lang.Thread.run(Thread.java:745)

the following are my beans

 <rabbit:queue id="reportQueue" name="reportQueue" durable="true" auto-delete="false" exclusive="false"/>


 <rabbit:direct-exchange id="reportExchange" durable="true" name="reportExchange">
     <rabbit:bindings>
        <rabbit:binding queue="reportQueue" key="reportBind"></rabbit:binding>
     </rabbit:bindings>
 </rabbit:direct-exchange>


  <bean id="aListener" class="com.sample.ReportMessageListener" autowire="byName"/>
  <bean id="reportMessageConverter" class="com.sample.ReportMessageConverter"/>
 <rabbit:listener-container id="myListenerContainer" connection-factory="connectionFactory" acknowledge="auto" prefetch="5" concurrency="1" message-converter="reportMessageConverter" >
    <rabbit:listener ref="aListener" queues="reportQueue"/>
</rabbit:listener-container>

Update:

with debug enabled the messages are

09 Jul 2015 14:46:35,284 [DEBUG] [main] SimpleMessageListenerContainer| Starting Rabbit listener container.
09 Jul 2015 14:46:38,601 [DEBUG] [elasticsearch[local_jvm_node][clusterService#updateTask][T#1]] service                  | [local_jvm_node] processing [routing-table-updater]: execute
09 Jul 2015 14:46:38,602 [DEBUG] [elasticsearch[local_jvm_node][clusterService#updateTask][T#1]] service                  | [local_jvm_node] processing [routing-table-updater]: no change in cluster_state
09 Jul 2015 14:46:40,324 [ERROR] [SimpleAsyncTaskExecutor-1] SimpleMessageListenerContainer| Failed to check/redeclare auto-delete queue(s).
java.util.concurrent.TimeoutException
    at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
    at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:111)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:367)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:621)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:665)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:208)
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:444)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1035)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1028)
    at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1004)
    at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:254)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:963)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$300(SimpleMessageListenerContainer.java:83)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1081)
    at java.lang.Thread.run(Thread.java:745)
09 Jul 2015 14:46:40,328 [DEBUG] [SimpleAsyncTaskExecutor-1] BlockingQueueConsumer    | Starting consumer Consumer: tags=[{}], channel=null, acknowledgeMode=MANUAL local queue size=0
09 Jul 2015 14:46:45,333 [DEBUG] [SimpleAsyncTaskExecutor-1] SimpleMessageListenerContainer| Recovering consumer in 5000 ms.

09 Jul 2015 14:46:50,402 [WARN ] [SimpleAsyncTaskExecutor-1] SimpleMessageListenerContainer| Consumer raised exception, processing can restart if the connection factory supports it
java.util.concurrent.TimeoutException
    at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:77)
    at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:111)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:37)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:367)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:621)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:665)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:208)
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:444)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:80)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:130)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:67)
    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:434)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1083)
    at java.lang.Thread.run(Thread.java:745)
09 Jul 2015 14:46:50,403 [INFO ] [SimpleAsyncTaskExecutor-1] SimpleMessageListenerContainer| Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=MANUAL local queue size=0
09 Jul 2015 14:46:50,403 [DEBUG] [SimpleAsyncTaskExecutor-1] BlockingQueueConsumer    | Closing Rabbit Channel: null
Pradeep
  • 850
  • 2
  • 14
  • 27

5 Answers5

4

Restarting RabbitMQ resolved this for me (Mac).

cd /usr/local/sbin 
./rabbitmqctl stop_app
./rabbitmqctl start_app
izilotti
  • 4,757
  • 1
  • 48
  • 55
1

It has nothing to do with auto-delete queues (except the fact that you have some means the container is initializing the connection at this particular point in its lifecycle).

You seem to have some network issues...

java.util.concurrent.TimeoutException
....
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:293)

The rabbitmq client library has a hard-coded 5 second timeout when waiting for the response for the connection start command and the server is not replying in time.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • 1
    i am running the client and rabbitmq on the same machine. and even with these error messages(these messages are continuous and not a one-time) producer and consumer are passing the messages fine. if this is a connection problem I believe the whole thing should nt be working. Please correct me if i am wrong. – Pradeep Jul 09 '15 at 17:58
  • Perhaps the problems are transient? If you turn on DEBUG logging you should get a lot more information. I know the timeout stuff was only recently added to the rabbit client that is used by Spring AMQP so there might be some new issue there; a DEBUG log should help. If it's too big to post here, try pastebin or a github gist. – Gary Russell Jul 09 '15 at 18:42
  • Yes the problem is transient. But I am getting these 8 out of 10 times i start my application. Added the messages with debug enabled in the question. Please let me know if you need any thing. Mean time, I am trying to investigate this by trying some other properties. – Pradeep Jul 09 '15 at 21:52
  • Nothing obvious from the logs. See if there is anything in the rabbitmq logs. – Gary Russell Jul 10 '15 at 04:43
  • I'd like to see a more complete log - including when the app starts working. – Gary Russell Jul 10 '15 at 13:11
1

I think it is about your spring-rabbit version. I encountered the same problem as you. but I have no idea to fix it. But in my another project, it works well. Then I compared two projects. I discovered the spring-rabbit version is different from each other.

<dependency>
  <groupId>org.springframework.amqp</groupId>
  <artifactId>spring-rabbit</artifactId>
  <version>1.6.5.RELEASE</version>
</dependency>

this new version throw TimeoutException. but

<dependency>
  <groupId>org.springframework.amqp</groupId>
  <artifactId>spring-rabbit</artifactId>
  <version>1.4.5.RELEASE</version>
</dependency>

this version it works well. my spring-boot version is "Camden.SR2".default spring-rabbit 1.6.5.RELEASE.

Hope it helps you

Changel
  • 61
  • 1
  • 3
1

I think you can try to change the port to 5672, it works for me

0

Perhaps you can try overriding the default handshakeTimeout by defining bean

com.rabbitmq.client.ConnectionFactory#setHandshakeTimeout 

Something like below:

<bean id="myConnectionFactory" class="com.rabbitmq.client.ConnectionFactory"
      p:automaticRecoveryEnabled="false" p:handshakeTimeout="${rabbit.handshakeTimeout:10000}">
 ....
</bean>
Shiva
  • 1,962
  • 2
  • 13
  • 31