Zamqp. ¼øÀ§ ¹× ¿ä¾à
- °Ô½ÃÀÚ À̸§:
- BlueDynamics Alliance
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://bluedynamics.com
Zamqp. ű×
Zamqp. ¼³¸í
ÆÄÀÌ½ã ¹× Zope ¿ë Amqp ¹æ¼Û ZAMQP´Â AMQP.ZAMQP¸¦ ÅëÇØ ÆÄÀ̽ã ÀνºÅϽº°£¿¡ ¸Þ½ÃÁö¸¦ ¹æ¼ÛÇÏ°í Æ®¸®°ÅÇÕ´Ï´Ù. amqplib¸¦ ±â¹ÝÀ¸·ÎÇÏ¸ç ¼ÒºñÀÚ ¹× »ý»êÀÚ ±¸ÇöÀ» Á¦°øÇÏ°í Zope À̺¥Æ®¸¦ Æ®¸®°ÅÇÏ´Â ¸ÞÄ¿´ÏÁòÀ» Á¦°øÇÕ´Ï´Ù. AMQP ¿¬°áÀ»À§ÇÑ Çï±â ClassesScreate ¼Ó¼º. amqpprops >>> props = amqpprops (host = 'localhost', ... user = 'guest', ... password = 'guest', ... ssl = false, ... Exchange = 'zamqp.broadcast.fanout ', ... ='fanout ', ... realm ='/ data ') ¼öµ¿À¸·Î AMQP ¿¬°áÀ» ¸¸µì´Ï´Ù. >>> zamqp °¡Á® ¿À±â amqpconnection >>> connection = amqpconnection ('zamqp_queue ', props) ¾×¼¼½º ¿¬°á ä³Î. >>> Connection.ChannelConsumer ¹× ProduceerCreate ¼ÒºñÀÚ Äݹé (¸Þ½ÃÁö) : ... Æнº # ¼ö½Å µÈ ¸Þ½ÃÁö Herecreate¿Í ÇÔ²² ¹«¾ùÀ̵ç ÇÏ½Ã°í ¼ÒºñÀÚ ½ÇÀ» ½ÃÀÛÇϽʽÿÀ. >>> Zamqp Import AmqPthread >>> Consumer = AmqPConsumer ( 'ZAMQP_QUEUE', PROP, Callback) >>> ½º·¹µå = amqpthread (¼ÒºñÀÚ) >>> thread.start () Á¦ÀÛÀÚ¸¦ ¸¸µé°í ¾û¸ÁÀ¸·Î º¸³»½Ê½Ã¿À. ¿¬·É´ë. Á÷·ÄÈ °¡´ÉÇÑ ¸ðµç ÆÄÀ̽㠰´Ã¼¸¦ ¸Þ½ÃÁö·Î »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. >>> ZAMQP °¡Á® ¿À±â amqpproducer¿¡¼ >>> Á¦ÀÛÀÚ = amqpproducer ( 'zamqp_queue', props) >>> ¸Þ½ÃÁö = 'foo'>>> Á¦ÀÛÀÚ (¸Þ½ÃÁö) Æ®¸®°Å À̺¥Æ® create ¿ø°Ý ÀνºÅϽº¿¡¼ Æ®¸®°ÅµÇ¾î¾ßÇÏ´Â À̺¥Æ®ÀÔ´Ï´Ù. >>> Class MyEvent (Object) : ... DEF __Init __ (ÀÚü, À̸§) : ... self.name = MyEventÀÇ ¸®½º³Ê¸¦ »ç¿ëÇÕ´Ï´Ù. ÀÌ°ÍÀº AMQP À̺¥Æ®°¡ ¼ö½Å µÉ ¶§ È£ÃâµË´Ï´Ù. >>> DEF MY_LISTENER (À̺¥Æ®) : ... iSInstance (À̺¥Æ®, MyEvent)°¡ ¾Æ´Ñ °æ¿ì ... ¹Ýȯ ... # ¹º°¡¸¦ÇϽʽÿÀ >>> °¡Á® ¿À±â zope.event >>> zope.event.subscribers.append (my_listener) ±âº» AMQPEventCallbackÀº zope.event.notify¸¦ È£ÃâÇϱ⠸¸ÇÏ¸é ´ÙÀ½°ú °°Àº ¼ö½Å µÈ ÆäÀ̷ε带 »ç¿ëÇÏ¿© Serialized À̺¥Æ® ÀÎ À̺¥Æ®ÀÇ ÀνºÅϽºÀÔ´Ï´Ù. = 'zamqp.events.fanout'>>> Queue = 'zamqp_events'>>> zamqp °¡Á® ¿À±â amqpeventcallback >>> props = amqpprops (Exchange = Exchange) >>> Äݹé = amqpeventcallback () >>> consumer = amqpconsumer (´ë±â¿ , ¼ÒÇ°, Äݹé) >>> thread = amqpthread (consumer) >>> thread.start () myEvent¿¡¼ amqp ä³ÎÀ» Æ®¸®°ÅÇÕ´Ï´Ù. ÀÌÀü¿¡ ½ÃÀÛµÈ À̺¥Æ® ¼ÒºñÀÚ °¡ÀÌ À̺¥Æ®¸¦ ¼ö½ÅÇÏ°í IT ÀÚü ÀÎÅÍÇÁ¸®ÅÍ¿¡¼ ·ÎÄ÷ΠƮ¸®°ÅÇÕ´Ï´Ù. >>> zamqp °¡Á® ¿À±â amqpevent >>> À̺¥Æ® = amqpevent (Å¥, ¼ÒÇ°, MyEvent ( 'myEvent)) >>> zope. ¾Ë¸² (À̺¥Æ®) ¿ä±¸ »çÇ× : ¡¤ ÆÄÀ̽ã
Zamqp. °ü·Ã ¼ÒÇÁÆ®¿þ¾î