最近在看QPID
首先看下QPID是什么,他是个消息队列,用他有什么好处呢 ,可以跨平台使用,比如业务部分用C实现,把需要共享的信息通过QPID来传递,然后JAVA侧再从QPID接受消息
QPID官网:
http://qpid.apache.org/download.html
JAVA开发的话可以先在官网上下载一个 Java broker, client & tools qpid-java-0.20.tar.gz [PGP]
bin/qpid-server.bat 就可以启动
后面先研究如下几点
1、java开发服务端
研究几点,点对点的消息 、广播消息
2、java开发客户端
点对点消息的接收,接收后如何删除已经读取过的消息,使用 message.acknowledge()
广播消息的接收
消息格式的解析,一般采用字符串格式
3、qpid是否有tool可以看到当前的缓存情况
可以使用 qpid-jmx-management-console-0.18-win32-win32-x86.zip
下载地址 :http://www.eu.apache.org/dist/qpid/0.18/
4、QPID的性能问题,比如一个缓存队列的最大记录数,qpid开启时候设置jdk的虚拟内存等等
表 1. AMQP 的几个概念
概念 描述
Producer A program that writes messages to an Exchange. To do this, the program creates a message, fills the message with content, gives the message a Routing Key, and sends the message to an Exchange.
Routing Key A string that the Exchangecan use to determine to which Queuesthe message should be delivered.
Exchange Accepts messages from Producersand routes them to Queuesif the message meets the criteria expressed in a binding.
Binding Defines the relationship between an Exchangeand a Queue, specifying which messages should be routed to a given Queue
Queue Holds messages and delivers them to the Consumersthat subscribe to the Queue.
Consumer A program that reads messages from a Queue. A Consumercan create, subscribe to, share, use, or destroy Queueand their Bindings(as long as it has have permission to do so).
为了支持各种常见的通信模型,AMQP 定义了不同的 Exchange 类型,如下表所示 :
表 2. AMQP 定义的 Exchange 类型
Exchange 类型 路由行为
Fan-Out Messages are routed to every Queue bound to the Exchange, ignoring the Routing Key
Direct A message is routed only if a Queue's Binding Keyis the same as the message's Routing Key
Topic Similar to a Direct Exchange, but it supports multipart keys that contain multiple words separated by the "." delimiter; for instance, a message Producer can create messages with Routing Keys like usa.news, usa.weather, europe.news, and europe.weather.
参考资料
消息中间件 Apache Qpid 简介,第 1-2 部分
http://www.ibm.com/developerworks/cn/opensource/os-cn-qpid1/index.html
http://www.ibm.com/developerworks/cn/opensource/os-cn-qpid2/index.html
刚刚才开始研究! 等后面再补充吧
export PYTHONPATH=/usr/local/bin/qpid-tools-0.18/python/:/usr/local/bin/qpid-tools-0.18/src/py/
cd /usr/local/bin/qpid-tools-0.18/src/py/
./qpid-stat -q
qpidd --max-connections 2048 --auth no -d --log-to-file /var/log/mbus.log --log-enable warning+