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
   72   73   74   75   76   77   78   79   80   81   82