Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pika unable to create quorum queue

Tags:

python

pika

i setup amazonMQ with RabbitMQ and try to use Pika to connect and publish messsage:

        credentials = pika.PlainCredentials(MQUSER, MQPW)
        amqs_str='amqps://'+MQUSER+':'+MQPW + '@'+MQURL+':'+str(MQPORT)+'/%2F'
        parameters= pika.URLParameters(amqs_str)
        connection = pika.BlockingConnection(parameters)
        channel= connection.channel()
        channel.queue_declare(queue=MQ_QUEUE_NAME,durable=True)

This will work, but the queue created is classic, and i understand quorum is much better in multi-node rabbitmq server. i search through pika documentation https://pika.readthedocs.io/en/0.10.0/modules/channel.html but couldnt find any settings to set quorum type queue. can anyone advice?

like image 570
desmond Avatar asked Oct 17 '25 06:10

desmond


1 Answers

Just tried it out - works by passing the queue type quorum when calling queue_declare.

Minimal working example. I tested with the rabbitMQ docker image: docker run -d --name rabbitMQ -p 5672:5672 -p 8080:15672 rabbitmq:3-management

import pika
con = pika.BlockingConnection(pika.ConnectionParameters("localhost"))
channel = con.channel()
channel.queue_declare(queue="test",durable=True,arguments={"x-queue-type": "quorum"})
like image 172
Bierbarbar Avatar answered Oct 18 '25 18:10

Bierbarbar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!