In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.