Page 77 - Python Cơ Bản
P. 77
import pika
connection = pika.BlockingConnection(pika.Connectio
nParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hel
lo', body='Hello World!')
print " [x] Sent 'Hello World!'"
connection.close()
ɇВ KЮM QШX QIWWEKI GLɾRK XE G϶R OЎX RРM чЎR WIVZIV Zɧ
OLEM FɨS QШX GLERRIP Ю чɩ] Pɧ GLERRIP Gɹ XɱR Pɧ hello
7EY OLM OLEM FɨS GLERRIP XES XMЎR LɧRL KЮM QIWWEKI Gɹ
RШM HYRK Hello World! XLɺRK UYE GLERRIP Rɧ] OɯQ XLIS
OLEM FɨS routing_key Pɧ hello 6SYXMRK /I] WЌ KMɾT чMАY
LЪRK QIWWEKI Rɧ] чЎR чɾRK GɨG [SVOIV чвG OLEM FɨS
RLϼR QIWWEKI XLIS VSYXMRK OI] 'SRWYQIV
2LϼR QIWWEKI 'SRWYQIV