Dmitrii Semenov
Dmitrii Semenov

Reputation: 325

Spring-amqp two queues with different TTL

In our application, we use RabbitMQ and spring-amqp(1.4.3.RELEASE). We have two Queues there. Both of them have TTL(60000 and 100000) configured. When we start the application, it gives the following errors:

[pool-4-thread-1] ERROR org.springframework.amqp.rabbit.connection.CachingConnectionFactory - Channel shutdown: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-message-ttl' for queue 'queue1' in vhost '/': received '60000' but current is '100000', class-id=50, method-id=10)

And then an exception is thrown when we try to send message to the queue:

[http-nio-8080-exec-8] ERROR [P181786EJG755SN8I3S74584216UV1] No reply received - perhaps a timeout in the template? org.springframework.remoting.RemoteProxyFailureException: No reply received - perhaps a timeout in the template? at org.springframework.amqp.remoting.client.AmqpClientInterceptor.invoke(AmqpClientInterceptor.java:60) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy83.getUserById(Unknown Source)

Search on the internet gave the following result:

http://forum.spring.io/forum/spring-projects/integration/amqp/124865-unexpected-behaviour-with-rabbit-admin And especially, this bug: https://jira.spring.io/browse/AMQP-266

After we have found that bug, we have changed TTL values for both queues to 60000, and Error is not shown anymore. And application is running fine. So, it seems that there is still a bug with TTL.

Upvotes: 4

Views: 9901

Answers (4)

GeezerP
GeezerP

Reputation: 11

The error thrown is usually something along the lines of inequivalent arg 'x-message-ttl' for queue 'your-queue' in vhost '/': received the value '10000' of type 'signedint' but current is none.

The reason is because on the rabbitmq console you've initialized the queue and your application is also trying to initialize the same queue.

As such as a solution, delete the queue you had defined and then run your application.

That should initialize your keys.

Upvotes: 1

enyavi
enyavi

Reputation: 51

I was facing same issue, but config was correct. Just delete the queue from rabbit management, and let spring create again on microservice startup, everything works fine now.

Upvotes: 0

Zaha
Zaha

Reputation: 946

Dmitrii Semenov Response is correct, Just for a suggestion:

"Try removing queue from rabbitmq-management"

NOTE: From docker you can access to "your ip or localhost":15672

enter image description here

enter image description here

Ref: https://github.com/streadway/amqp/issues/60#issuecomment-18119437

Upvotes: 4

Dmitrii Semenov
Dmitrii Semenov

Reputation: 325

I have found the problem, it was related to wrong configuration. So, to troubleshoot this problem:

  1. Check, that Queue declared in the Rabbit-Server has same parameters in spring-configurations. Good thing this is to remove completely queues from rabbit and start application.
  2. In the applications there could be several places where queues can be declared. Check that all of them have same parameters. If they have different parameters, it can lead to problem (That was my case).

Upvotes: 5

Related Questions