In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Sender:
Import pikaimport sysconnection = pika.BlockingConnection (pika.ConnectionParameters (host='localhost')) channel = connection.channel () channel.exchange_declare (exchange='logs',exchange_type='fanout') message = '.join (sys.argv [1:]) or "info: Hello World!" channel.basic_publish (exchange='logs', routing_key='', body=message) print ("[x] Sent% r"% message) connection.close ()
Receiving end:
Import pikaconnection = pika.BlockingConnection (pika.ConnectionParameters (host='localhost')) channel = connection.channel () channel.exchange_declare (exchange='logs', exchange_type='fanout') result = channel.queue_declare (exclusive=True) # do not specify a queue name, rabbit will randomly assign a name, exclusive=True will disconnect after consumers using this queue Automatically delete queue queue_name = result.method.queueprint (queue_name) channel.queue_bind (exchange='logs', queue=queue_name) print ('[*] Waiting for logs. To exit press CTRL+C') def callback (ch, method, properties, body): print ("[x]% r"% body) channel.basic_consume (callback, queue=queue_name, no_ack=True) channel.start_consuming ()
Exchange will not save the data, and if it is not accepted by the client, it will be discarded, that is, the client will lose the data sent by the sender before startup.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.