PDA

View Full Version : passing x-expires argument to queue



kkcmadhu
May 18th, 2012, 12:50 PM
Hi I want to set x-expire time for the queues which are created in rabbit
and i am using <rabbit:queue> tag for the same. But looks like rabbit/spring takes the value as string and is not able to set this property to the queue.




<rabbit:queue name="test.noConsumerQueue" auto-delete="true">
<rabbit:queue-arguments>
<entry key="x-expires" value="10000"/>
</rabbit:queue-arguments>

</rabbit:queue>


I am getting this exection



Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - invalid arg 'x-expires' for queue 'test.noConsumerQueue' in vhost '/': {unacceptable_type,longstr}, class-id=50, method-id=10),null,""}
at com.rabbitmq.utility.ValueOrException.getValue(Val ueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.unin terruptibleGetValue(BlockingValueOrException.java: 33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcCon tinuation.getReply(AMQChannel.java:328)
at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel .java:201)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc (AMQChannel.java:125)
... 22 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - invalid arg 'x-expires' for queue 'test.noConsumerQueue' in vhost '/': {unacceptable_type,longstr}, class-id=50, method-id=10),null,""}
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(Ch annelN.java:384)
at com.rabbitmq.client.impl.ChannelN.processAsync(Cha nnelN.java:235)
at com.rabbitmq.client.impl.AMQChannel.handleComplete InboundCommand(AMQChannel.java:151)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AM QChannel.java:96)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.ru n(AMQConnection.java:441)
[Thread : SimpleAsyncTaskExecutor-4] 2012-05-18 10:43:03,562 INFO [org.springframework.am


is there a way to pass the value as int/long instead of string?
Am i missing something here?

How ever i also noticed that the queue does get created in the broker, but without this argument.

Gary Russell
May 18th, 2012, 01:23 PM
You need to give the arguments a value-type...



<rabbit:queue-arguments value-type="java.lang.Long">
<beans:entry key="x-message-ttl" value="100" />
</rabbit:queue-arguments>


For arguments of mixed types, the syntax is a little clunky, see my comment near the end of https://jira.springsource.org/browse/AMQP-198

However, this is improved in Spring 3.2 and may be back ported to Spring 3.1.

https://jira.springsource.org/browse/SPR-9249