真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

rabbitmq遠(yuǎn)程消費(fèi)者生產(chǎn)者發(fā)送端接收端實(shí)例-創(chuàng)新互聯(lián)

rabbit_remote_send_procedure.py

創(chuàng)新互聯(lián)長(zhǎng)期為上千家客戶(hù)提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為長(zhǎng)垣企業(yè)提供專(zhuān)業(yè)的網(wǎng)站設(shè)計(jì)、做網(wǎng)站,長(zhǎng)垣網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。

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

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

# 聲明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 發(fā)送的消息
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默認(rèn)端口5672 建立一個(gè)基本的 socket連接
channel = connection.channel()#聲明一個(gè)管道 在管道里面收消息

# 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


defcallback(ch, method, properties, body):
    print("---->",ch,method,properties)#ch 管道內(nèi)存對(duì)象地址 method:發(fā)給queue的信息
    print(" [x] Received %r"% body)


channel.basic_consume(#消費(fèi)消息
                      callback,#如果收到消息,就調(diào)用CALLBACK函數(shù)來(lái)處理消息
                      queue='hello1',#從哪個(gè)隊(duì)列里收消息
                      no_ack=True
)

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

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。


標(biāo)題名稱(chēng):rabbitmq遠(yuǎn)程消費(fèi)者生產(chǎn)者發(fā)送端接收端實(shí)例-創(chuàng)新互聯(lián)
文章分享:http://weahome.cn/article/dcdccs.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部