Announcement Announcement Module
Collapse
No announcement yet.
passing x-expires argument to queue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • passing x-expires argument to queue

    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.

    Code:
      <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

    Code:
    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(ValueOrException.java:67)
    	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
    	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.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(ChannelN.java:384)
    	at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:235)
    	at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:151)
    	at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:96)
    	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(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.

  • #2
    You need to give the arguments a value-type...

    Code:
    	<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

    Comment

    Working...
    X