RabbitMQ hello word (python)
来源:互联网 发布:caffe官方教程中译本 编辑:程序博客网 时间:2024/05/20 10:14
RabbitMQ tutorials:
http://www.rabbitmq.com/tutorials/tutorial-one-Python.html
send.py
- #! /srv/python2/bin/python
- # -*- coding: utf-8 -*-
- import pika
- __author__ = 'nick'
- def send():
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- 'localhost'))
- channel = connection.channel()
- channel.queue_declare(queue='hello')
- channel.basic_publish(exchange='',
- routing_key='hello',
- body='Hello World!')
- print(" [x] Sent 'Hello World!'")
- connection.close()
- if __name__ == '__main__':
- send()
receive.py
- #! /srv/python2/bin/python
- # -*- coding: utf-8 -*-
- import pika
- __author__ = 'nick'
- def callback(ch, method, properties, body):
- print(" [x] Received %r" % body)
- def receive():
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- 'localhost'))
- channel = connection.channel()
- channel.queue_declare(queue='hello')
- channel.basic_consume(callback,
- queue='hello',
- no_ack=True)
- print(' [*] Waiting for messages. To exit press CTRL+C')
- channel.start_consuming()
- if __name__ == '__main__':
- receive()
0 0
- RabbitMQ hello word (python)
- RabbitMQ 简单Hello Word
- python的Hello Word
- python的Hello Word
- 1> python hello word
- Python基础01 hello word
- python系列之 RabbitMQ - hello world
- python自学 hello word(一)
- Python学习——Pycharm“Hello Word”
- RabbitMQ学习小结(一)—— Hello World [Python]
- hello word
- hello word
- Hello,Word?
- hello word!
- Hello Word
- hello word
- hello word
- hello word!
- 基于Linux下的TCP编程
- Linux 快速定位vi 文件字符串
- django系列 4:模板引擎
- 花生壳(内网穿透)客户端【申明:来源于网络】
- 列表
- RabbitMQ hello word (python)
- 论程序员学习之路
- 产生报表用例的详细描述
- 定位
- 基于Linux下的UDP编程
- RabbitMQ管理后台
- guava系列之前置检查
- 【转】京东抢购服务高并发实践
- 复杂选择器1