tobby48 4 years ago
parent
commit
11b631220e

+ 1
- 1
src/main/python/kr/co/swh/lecture/opensource/rabbitmq/receive.py View File

9
         self.__queue = 'py'; 
9
         self.__queue = 'py'; 
10
     
10
     
11
     def on_message(channel, method_frame, header_frame, body): 
11
     def on_message(channel, method_frame, header_frame, body): 
12
-        print('Received %s' % body) 
12
+        print('Received %s' % body.decode()) 
13
     
13
     
14
     def main(self): 
14
     def main(self): 
15
         conn = pika.BlockingConnection(pika.ConnectionParameters(self.__url, self.__port, self.__vhost, self.__cred)) 
15
         conn = pika.BlockingConnection(pika.ConnectionParameters(self.__url, self.__port, self.__vhost, self.__cred)) 

+ 1
- 1
src/main/python/kr/co/swh/lecture/opensource/rabbitmq/send.py View File

11
     def main(self): 
11
     def main(self): 
12
         conn = pika.BlockingConnection(pika.ConnectionParameters(self.__url, self.__port, self.__vhost, self.__cred)) 
12
         conn = pika.BlockingConnection(pika.ConnectionParameters(self.__url, self.__port, self.__vhost, self.__cred)) 
13
         chan = conn.channel() 
13
         chan = conn.channel() 
14
-        chan.basic_publish( exchange = '', routing_key = self.__queue, body = 'Hello RabbitMQ' ) 
14
+        chan.basic_publish( exchange = '', routing_key = self.__queue, body = '하이'.encode('utf-8') ) 
15
         conn.close() 
15
         conn.close() 
16
 
16
 
17
 publisher = Publisher() 
17
 publisher = Publisher()