91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

rabbitmq遠程消費者生產者發送端接收端實例

發布時間:2020-07-01 23:24:38 來源:網絡 閱讀:513 作者:leiwenbin627 欄目:編程語言

rabbit_remote_send_procedure.py

#!_*_coding:utf-8_*_
import pika
credentials=pika.PlainCredentials('lwb','123456')

connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.81.100',port=5672,virtual_host='/',credentials=credentials))#rabbit默認端口5672 建立一個基本的 socket連接
channel = connection.channel()#聲明一個管道 在管道里面發消息

# 聲明queue
channel.queue_declare(queue='hello5')

# n RabbitMQ a message can never be sent directly to the queue, it always needs to go through an exchange.
channel.basic_publish(exchange='',
                      routing_key='hello5',#queue名字
                      body='Hello World!') #body 發送的消息
print(" [x] Sent 'Hello World!'")
connection.close()

 

 

rabbitmq_recive_consumer.py

#!_*_coding:utf-8_*_
__author__ = 'Alex Li'
import pika
credentials=pika.PlainCredentials('lwb','123456')
connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.81.100',port=5672,virtual_host='/',credentials=credentials)) #rabbit默認端口5672 建立一個基本的 socket連接
channel = connection.channel()#聲明一個管道 在管道里面收消息

# You may ask why we declare the queue again ? we have already declared it in our previous code.
# We could avoid that if we were sure that the queue already exists. For example if send.py program
# was run before. But we're not yet sure which program to run first. In such cases it's a good
# practice to repeat declaring the queue in both programs.
channel.queue_declare(queue='hello1')#聲明queue


def callback(ch, method, properties, body):
    print("---->",ch,method,properties)#ch 管道內存對象地址 method:發給queue的信息
    print(" [x] Received %r" % body)


channel.basic_consume(#消費消息
                      callback,#如果收到消息,就調用CALLBACK函數來處理消息
                      queue='hello1',#從哪個隊列里收消息
                      no_ack=True
                     )

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()#啟動 開始收消息 一直收,沒有就卡主

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宁阳县| 廉江市| 公主岭市| 抚州市| 江西省| 平陆县| 滦平县| 陕西省| 上杭县| 共和县| 吴江市| 潮安县| 南平市| 南川市| 繁峙县| 石阡县| 阿勒泰市| 灵宝市| 故城县| 兴国县| 永平县| 建水县| 洛南县| 苗栗县| 房山区| 南涧| 宁夏| 志丹县| 丽江市| 松滋市| 亳州市| 建湖县| 西城区| 达尔| 恩平市| 登封市| 临漳县| 贞丰县| 新化县| 高州市| 黎川县|