Kombu Exchange
来源:互联网 发布:c语言数组实验报告 编辑:程序博客网 时间:2024/05/16 15:10
本文地址:http://blog.csdn.net/spch2008/article/details/11569127
示例代码:
from kombu.entity import Exchange, Queuefrom kombu.messaging import Consumerfrom kombu.connection import Connectionconnection = Connection('amqp://guest:bupt@172.16.4.1:5672//')channel = connection.channel()news_exchange = Exchange('news', type='topic')bound_exchange = news_exchange(channel)bound_exchange.declare()第9行声明一个Exchange,并不能再上面执行任何操作,只是描述了一下这个Exchange的特性。
第10行将exchange与特定的channel进行绑定。内部其实只是复制了自身,然后将_channel赋值而已。(Exchange内部记住了channel)
def __call__(self, channel): return self.bind(channel)def bind(self, channel): return copy(self).maybe_bind(channel)def maybe_bind(self, channel): if not self.is_bound and channel: self._channel = channel self.when_bound() self._is_bound = True return selfdef when_bound(self): pass第11行,在服务器上创建Exchange。这样,通过命令rabbitmqctl list_exchanges就可以看到创建的exchange。
参数说明:
class kombu.Exchange(name='', type='', channel=None, **kwargs)Parameters:name - Exchange名字 type – direct, fanout,topic,header几种类型 channel – Exchange需要绑定的channel durable – server重启后是否恢复Exchange,默认True,即重启后Exchange仍然存在 delivery_mode – transient模式,消息只存储于内存server重启或死机,消息丢失。 persistent模式,消息存在内存与硬盘,信息不丢失,默认persistent。
函数说明:
declare(self, nowait=False) server上创建Exchange nowait True 不等待Server的响应信息。delete(self, if_unused=False, nowait=False) server上删除Exchange if_unused True只在Exchange没有使用的时候删除
- Kombu Exchange
- kombu websites
- Kombu 基础
- Kombu Queue
- Kombu Consumer
- Kombu 基础
- Kombu socked closed
- nova oslo.messageing kombu
- Kombu小练习
- OpenStack基础之Kombu
- kombu消息框架<一>
- kombu消息框架<二>
- Exchange
- OpenStack基础组件kombu杂谈
- AMQP,RabbitMQ,Qpidd和Kombu
- kombu------python的消息库
- openstack nova 基础知识——Kombu
- openstack nova 基础知识——Kombu
- StringBuilder与StringBuffer的区…
- 【小龙女陈妍希古装Win7主题】
- nutch工程源码导入Eclipse过…
- nutch搜索引擎的搭建以及配置
- cygwin一闪而过 的处理(小经验)
- Kombu Exchange
- Windows下开源搜索引擎Nutch…
- nutch项目中到hadoop到mapreduce
- 如何把word文档按照单元格放进excel中
- 利用Nutch和IKanalyzer构造中文分…
- [Java]读取文件方法大全
- PowerDesigner15官方正式版+…
- TCP/IP协议,HTTP协议
- java的awt和swing