Can't connect to priority queue with JMS client

535 views
Skip to first unread message

Stephen Dewitt

unread,
Mar 10, 2016, 2:40:43 PM3/10/16
to rabbitmq-users
I'm using RabbitMQ 3.5.6 and rabbitmq-jms-1.4.6.  When I create a queue in the RabbitMQ console the x-max-priority argument, I can't connect to this queue from my JMS client.

I'm using fscontext for JNDI, with a .bindings file that looks like this:

ConnectionFactory/ClassName=javax.jms.ConnectionFactory
ConnectionFactory/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/0/Content=jms/ConnectionFactory
ConnectionFactory/RefAddr/0/Type=name
ConnectionFactory/RefAddr/0/Encoding=String
ConnectionFactory/RefAddr/1/Content=javax.jms.ConnectionFactory
ConnectionFactory/RefAddr/1/Type=type
ConnectionFactory/RefAddr/1/Encoding=String 
ConnectionFactory/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
ConnectionFactory/RefAddr/2/Type=factory
ConnectionFactory/RefAddr/2/Encoding=String
ConnectionFactory/RefAddr/3/Content=localhost
ConnectionFactory/RefAddr/3/Type=host
ConnectionFactory/RefAddr/3/Encoding=String
PriorityQ/ClassName=javax.jms.Queue
PriorityQ/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory
PriorityQ/RefAddr/0/Content=jms/Queue
PriorityQ/RefAddr/0/Type=name
PriorityQ/RefAddr/0/Encoding=String
PriorityQ/RefAddr/1/Content=javax.jms.Queue
PriorityQ/RefAddr/1/Type=type
PriorityQ/RefAddr/1/Encoding=String
PriorityQ/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory
PriorityQ/RefAddr/2/Type=factory
PriorityQ/RefAddr/2/Encoding=String
PriorityQ/RefAddr/3/Content=priorityQ
PriorityQ/RefAddr/3/Type=destinationName
PriorityQ/RefAddr/3/Encoding=String

And "priorityQ" is the priority queue I created in the console.

I've got a very simple JMS program (cribbed from the Sun JMS tutorial) and I blow up here:

        try {
            connection = connectionFactory.createConnection();

            Session session =
                connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            producer = session.createProducer(dest);

when I try to create the producer, with the following error:

120 [main] ERROR com.rabbitmq.jms.client.RMQSession - RabbitMQ exception on queue declare name(priorityQ), durable(true), exclusive(false), auto-delete(false), properties(null)

java.io.IOException

       at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)

       at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)

       at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)

       at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:844)

       at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:61)

       at com.rabbitmq.jms.client.RMQSession.declareRMQQueue(RMQSession.java:769)

       at com.rabbitmq.jms.client.RMQSession.declareDestinationIfNecessary(RMQSession.java:552)

       at com.rabbitmq.jms.client.RMQSession.createProducer(RMQSession.java:543)

       at SimpleProducer.main(SimpleProducer.java:130)

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-max-priority' for queue 'priorityQ' in vhost '/': received none but current is the value '10' of type 'long', class-id=50, method-id=10)

       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:361)

       at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:226)

       at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)

       ... 6 more

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-max-priority' for queue 'priorityQ' in vhost '/': received none but current is the value '10' of type 'long', class-id=50, method-id=10)

       at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:484)

       at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:321)

       at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)

       at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)

       at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:554)

       at java.lang.Thread.run(Unknown Source)


Does anyone have any ideas?

Thanks,

Steve

Michael Klishin

unread,
Mar 10, 2016, 3:31:41 PM3/10/16
to rabbitm...@googlegroups.com

On 10 mar 2016, at 22:40, Stephen Dewitt <stephen...@gmail.com> wrote:

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-max-priority' for queue 'priorityQ' in vhost '/': received none but current is the value '10' of type 'long', class-id=50, method-id=10)

Once declared, queue properties cannot change. Your declare uses arguments different from what is already there. Delete the queue and try again.

Stephen Dewitt

unread,
Mar 10, 2016, 3:40:51 PM3/10/16
to rabbitmq-users
Thanks for the quick response.  The thing is, I don't want to change the queue properties.  I want to use the existing queue just as it was declared.  Is there a way I can specify additional properties for the queue in JMS to match the original arguments?  Maybe as a reference in the JNDI binding or something like that?

Gary Russell

unread,
Mar 10, 2016, 5:14:05 PM3/10/16
to rabbitm...@googlegroups.com
By default, the JMS client attempts to declare the queue with no arguments.

You can suppress the declaration by setting the amqp property on the destination to true which means the destination maps to an existing resource.
 
If you use the 4 arg constructor (the one with the exchange and routing key) it is set to true (it's false with the "normal" - JMS - constructor).

There is also a setter setAmqp(boolean amqp).

If the property is true before you create the producer, it should skip the declaration with mismatched args.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Dewitt

unread,
Mar 10, 2016, 11:07:55 PM3/10/16
to rabbitmq-users
Thanks so much, Gary.  That's just what I was hoping for.  I set amqp and amqpQueueName in my .bindings file and I was able to send messages to the priority queue.

The only catch seems to be that I am also required to supply amqpExchangeName and amqpRoutingKey when I set amqp true.  According to the doc I found at http://pubs.vmware.com/vfabric53/index.jsp?topic=/com.vmware.vfabric.rabbitmq.3.2/jms-client/install-configure-client.html, these properties should default to null when amqp is true.  When I added the exchange name property but left the value empty, my messages were sent successfully, but never actually made it to the queue.  So, I bound my test queue to an exchange and supplied the exchange name-- and then everything worked like a charm.
Message has been deleted

Stephen Dewitt

unread,
Mar 11, 2016, 10:15:49 AM3/11/16
to rabbitmq-users
One last note on this-- instead of explicitly binding my queue to an exchange, I was also able to specify the the default exchange in my JNDI binding by leaving the content of the amqpExchangeName property empty and setting the amqpRoutingKey property to the queue name.  So, in my fscontext .bindings file, the binding for the priority queue now looks like:

PriorityQ/ClassName=javax.jms.Queue

PriorityQ/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory

PriorityQ/RefAddr/0/Content=jms/Queue

PriorityQ/RefAddr/0/Type=name

PriorityQ/RefAddr/0/Encoding=String

PriorityQ/RefAddr/1/Content=javax.jms.Queue

PriorityQ/RefAddr/1/Type=type

PriorityQ/RefAddr/1/Encoding=String

PriorityQ/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory

PriorityQ/RefAddr/2/Type=factory

PriorityQ/RefAddr/2/Encoding=String

PriorityQ/RefAddr/3/Content=priorityQ

PriorityQ/RefAddr/3/Type=destinationName

PriorityQ/RefAddr/3/Encoding=String

PriorityQ/RefAddr/4/Content=true

PriorityQ/RefAddr/4/Type=amqp

PriorityQ/RefAddr/4/Encoding=String

PriorityQ/RefAddr/5/Content=priorityQ

PriorityQ/RefAddr/5/Type=amqpQueueName

PriorityQ/RefAddr/5/Encoding=String

PriorityQ/RefAddr/6/Content=

PriorityQ/RefAddr/6/Type=amqpExchangeName

PriorityQ/RefAddr/6/Encoding=String

PriorityQ/RefAddr/7/Content=priorityQ

PriorityQ/RefAddr/7/Type=amqpRoutingKey

PriorityQ/RefAddr/7/Encoding=String

Reply all
Reply to author
Forward
0 new messages