Search code examples
rubyqueuerabbitmqmessage-queuebunny

Getting a queue without providing its all properties


I am trying to write a consumer for an existing queue.

RabbbitMQ is running in a separate instance and queue named "org-queue" is already created and binded to an exchange. org-queue is a durable queue and it has some additional properties as well.

Now I need to receive messages from this queue. I have use the below code to get instance of the queue

conn = Bunny.new
conn.start
ch = conn.create_channel    
q = ch.queue("org-queue")

It throws me an error stating different durable property. It seems by default the Bunny uses durable = false. So I've added durable true as parameter. Now it states the difference between other parameters. Do I need to specify all the parameters, to connect to it? As rabbitMQ is maintained by different environment, it is hard for me to get all the properties.

Is there a way to get list of queues and listening to the required queue in client instead of connecting to a queue by all parameters.


Solution

  • Have you tried the :passive=true parameter on queue()? A real example is the rabbitmq plugin of logstash. :passive means to only check queue existence rather than to declare it when consuming messages from it.