Get the App
SLTechnology News&Howtos  ›  Development  › 

What does rabbitmq mean in python

Shulou Source: shulou.com Published: 2022-06-03 17:34:09 10月01日 Update

This article is about what rabbitmq refers to in python. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. When a message becomes dead in a queue, it can be re-sent to DLX. The queue bound to DLX is called rabbitmq.

Also known as the dead letter queue.

2. it is commonly used in automatic cancellation of overtime orders, advance reminders of meeting reservations, and so on.

Example

Import pikaimport jsonimport time credentials = pika.PlainCredentials ('admin',' admin') # mq username and password # the virtual queue needs to specify the parameter virtual_host, which can be left empty if it is the default. Connection = pika.BlockingConnection (pika.ConnectionParameters (host='127.0.0.1', port=5672, credentials=credentials)) channel = connection.channel () # declares the message queue in which the message will be delivered if it does not exist Then create queue_name = "delay_queue_a" exchange = 'delay_exchange_a'routing_key =' delay_routing_key_a'dead_letter_exchange = 'dead_exchange_a' #' amq.direct'#'dead_exchange_a'dead_letter_routing_key = 'dead_letter_routing_key_a' #' dead_queue_a'#'dead_letter_routing_key_a'arguments = {"x-message-ttl": 5000 Dead_letter_routing_key} channel.confirm_delivery () channel.exchange_declare (exchange=exchange, durable=True, exchange_type='direct') result = channel.queue_declare (queue=queue_name, durable=False, arguments=arguments) channel.queue_bind (exchange=exchange, queue=queue_name) Routing_key=routing_key) for i in range (10): message = json.dumps ({'OrderId': I}) # insert a number into the queue routing_key is the queue name channel.basic_publish (exchange=exchange, routing_key=routing_key, body=message, properties=pika.BasicProperties (delivery_mode=2)) print (message) time.sleep (1.5) connection.close () Thank you for reading! This is the end of the article on "what does rabbitmq in python refer to?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Queues content more dead messages messages articles good practical meetings meeting reservations information parameters instances passwords numeric values articles users user names see knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia Shulou Technology Linux MySQL