Repository URL to install this package:
|
Version:
2.0.0 ▾
|
pp-python-commons
/
rabbit_create_queue_script.py
|
|---|
import pika
host = ""
user = ""
password = ""
exchange = ""
queue = ""
queue_dlq = ""
credentials = pika.PlainCredentials(user, password)
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host,
virtual_host="/",
heartbeat=600,
blocked_connection_timeout=300,
credentials=credentials,
)
)
channel = connection.channel()
channel.exchange_declare(exchange=exchange, exchange_type="fanout", durable=True)
channel.queue_declare(queue=queue_dlq, durable=True, arguments={"x-queue-type": "classic"})
channel.queue_declare(
queue=queue,
durable=True,
arguments={
"x-queue-type": "classic",
"x-dead-letter-exchange": "",
"x-dead-letter-routing-key": queue_dlq,
},
)
channel.queue_bind(exchange=exchange, queue=queue)