qpid初学

参考:
Redhat 6.3 qpid broker的源码安装及其配置
http://blog.chinaunix.net/uid-21335514-id-3555034.html
 
消息中间件 Apache Qpid 简介
https://www.ibm.com/developerworks/cn/opensource/os-cn-qpid1/
http://www.ibm.com/developerworks/cn/opensource/os-cn-qpid2/
qpid-config add queue hello-world
当创建一个 Queue 节点时,Qpid 会创建一个 AMQP Queue,和一个 Binding。缺省情况下用 Queue 的名字作为 RouteKey 和一个 Direct Exchange 进行绑定。
$qpid-config add exchange topic hello-world
当使用所谓 Topic 节点作为 Address 时,在底层,Qpid Client 库会自动建立所需要的 AMQP Queue 和 Binding。其底层依然符合 AMQP 的模型。只不过类似建立 binding,创建 Queue 等工作由 Qpid 的 client 库代劳了,应用程序无需考虑这些。


默认情况下,Broker 启动之后,会自动创建一些 Exchange(交换器),对应 AMQP 标准定义的那几个标准的 exchange 类型。分别叫做
amp.topic
amp.direct
amp.fanout


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'sBinding 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.


旧版本
http://qpid.apache.org/releases/index.html#past-releases
更老版本:
http://archive.apache.org/dist/qpid/


jms介绍
http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html


jms pdf
http://qpid.apache.org/releases/qpid-0.32/index.html


jms javadoc
http://docs.oracle.com/javaee/6/api//javax/jms/package-summary.html


AMQP Messaging Broker (Java)
https://qpid.apache.org/releases/qpid-0.32/java-broker/book/index.html


qpid client api(网上找不到0.32的doc,直接使用gradle自动下载就好了)
http://people.apache.org/~grkvlt/qpid-site/qpid-java/qpid-client/apidocs/index-all.html


---QPID网站很多(下载)链接都是乱的,doc也很混乱的,要有心理准备。


https://cwiki.apache.org/confluence/display/qpid/qpid+java+build+how+to


The releaseable Client and Broker binary packages can be found in the following locations locally if required for testing.
Broker
qpid/java/broker/target/qpid-broker-VERSION-bin.tar.gz
http://qpid.apache.org/releases/qpid-trunk/java-broker/book/Java-Broker-Installation.html
Once you have this then follow the Java Broker installation instructions.


Client
qpid/java/client/target/qpid-client-VERSION-bin.tar.gz
https://qpid.apache.org/components/jms/index.html
Once you have this then refer to the JMS client documentation.


所有的能下载的都下了,版本关系:
Qpid JMS (AMQP 1.0) apache-qpid-jms-0.1.0-bin.tar.gz*^
Qpid JMS (AMQP 0-10, 0-9-1, 0-9, 0-8) qpid-client-0.32-bin.tar.gz
Qpid JMS (AMQP 1.0) qpid-amqp-1-0-client-jms-0.32-bin.tar.gz
Earlier AMQP 1.0 JMS Client:Before the new Qpid JMS AMQP 1.0 client became available, the Qpid project offered an earlier AMQP 1.0 JMS client based on some initial prototyping work




启动broker,就不说了(待补充)


1,试着跑apache-qpid-jms-0.1.0的HelloWorld(qpid jms实现,AMQP 1.0???从jar包看似乎没有amqp的东西),结果报错
http://qpid.apache.org/components/jms/index.html#documentation
example根据pom引用jar,参考readme文档
javax.jms.InvalidDestinationException: Received error from remote peer without description [condition = amqp:not-found]
因为没有指定的queue
//jndi.properties
queue.myQueueLookup = queue


qpid-tools的安装和使用
使用qpid-tools (安装这个很简单,python的)
同样到apache官网下载,解压,安装(C++ broker?名字叫错了)
C++ broker (command-line tools) qpid-tools-0.32.tar.gz
python setup.py install


python装的2.7.9版本,需要run启动cmd再cd到指定目录运行,直接在指定目录找不到python命令,神奇


2,试着加个queue
http://qpid.apache.org/releases/qpid-0.32/programming/book/section-addresses.html
python qpid-config add queue hello-world
继续加queue


报错:找不到依赖模块
ImportError: No module named qpid.messaging
下载Qpid Messaging API (Python) qpid-python-0.32.tar.gz
python setup.py install


报错:没有权限
Failed: AuthenticationFailure: Anonymous connections disabled, missing credentials
修改work目录的配置qpidwork\config.json,改成匿名访问
http://qpid.apache.org/releases/qpid-0.32/java-broker/book/Java-Broker-Management-Managing-Authentication-Providers.html#Java-Broker-Management-Managing-Authentication-Providers-Types
 "authenticationproviders" : [ {
"type" : "Anonymous"
重启broker,继续加queue
python qpid-config add queue hello-world
Failed: NotFound: no such topic: qmf.default.topic


3,使用Qpid: Broker控制台来加queue(经咨询,发现不需要通过以上方式添加queue,也无需用到python,只需要专注jms文档,tom说不需要jndi)
http://localhost:8080/
用户名密码:guest/guest(D:\d\run\qpid\qpid-broker\0.32\etc\passwd)
broker-virtual host-add queue-create queue
创建queue后,一口气,跑完了
(AMQP 1.0最新版)
HelloWorld.java
Receiver.java
Sender.java


4,试着跑qpid-amqp-1-0-client-jms的Hello(qpid amqp实现,AMQP 1.0早期版)


5,试着跑qpid-client的Hello(qpid amqp实现,AMQP 0-10)


6,试着跑TestTopicPubSub(tom给的例子。放入qpid-client工程,暂时跑不起来)


7,AMQP 0-8, 0-9 and 0-9-1
http://qpid.apache.org/releases/qpid-0.32/jms-client-0-8/book/index.html
深入学习qpid-client


5.4.3. CreateQueue,5.4.4. CreateTopic
这2个方法不建议使用,建议在JNDI中定义Destinations 


5.5. MessageProducer
 If the application requires certainty the message has been received by the Broker, a transactional session must be used, or synchronous publishing must be enabled using either the system property or the connection URL option.


5.7. Destinations
A Destination is either a Queue or Topic. In the Qpid JMS client a Destination encapsulates a Binding URL. In simple terms, the Binding URL comprises of an exchange, queue and a routing key. 


http://qpid.apache.org/releases/qpid-0.32/jms-client-0-8/book/JMS-Client-0-8-Client-Understanding-MessageConsumer.html
这里说如果没有queue,Session#createConsumer() 会自动创建。apache-qpid-jms-0.1.0工程中却需要手动创建(可以吗,好像行不通),可能是jar包不同吧,以前的不支持


手动创建queue:
http://qpid.apache.org/releases/qpid-0.32/jms-client-0-8/book/JMS-Client-0-8-Appendix-JMS-Extensions.html


手动binding
http://qpid.apache.org/releases/qpid-0.32/jms-client-0-8/book/JMS-Client-0-8-Appendix-JMS-Extensions-Binding.html


8,通过文档学习qpid-client的其他例子
http://qpid.apache.org/releases/qpid-0.32/programming/book/index.html
ListSender里可以创建queue


Spout/Drain例子运行,传一个队列作为参数
Example 2.4. Queues
Create a queue with qpid-config, send a message using spout, and read it using drain:
$ qpid-config add queue hello-world
$ ./spout hello-world
$ ./drain hello-world


qpid的文档太难看了,到现在还没有看到topic的例子,以后有时间再细读英文文档,初步学习,到此为止
java-broker-book.pdf
jms_client08-book.pdf
programming-book.pdf
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值