Apache Qpid Java实战

0、官网:Apache Qpid

1、搭建Broker:Broker for Java

  这一步比较简单,按照Broker book即可完成。如果服务器有多个IP地址,需要绑定到某个IP的话,需要设置属性。参考Way to bind qpid to a different IP?

  引用重点部分如下:

For the AMQP port you need to set the bindingAddress parameter for the 
port, e.g.: 

{ 
    "authenticationProvider" : "passwordFile", 
    "bindingAddress" : "192.168.105.83", 
    "id" : "7236a3e5-9e74-440b-888b-2fdfcbe21695", 
    "name" : "AMQP", 
    "port" : 5672 
  } 

2、运行客户端(Sender & Receiver):Apache Qpid JMS Client for AMQP 0-10

  如果想偷懒的话,直接下载Qpid JMS for AMQP 0-9-1/0-10,修改ListSender.java和ListReceiver.java的new AMQConnection的url部分即可运行。详情参考Connection URLs

  先运行ListSender,然后在HTTP管理页面(用户名、密码参见broker根目录下etc/passwd文件)里,Broker - Virtual Hosts - 选中default - Virtual Host - View。Queues栏里应该能看到message_queue,其Depth(Bytes)应该为328B。

  接着运行ListReceiver(用-l参数即可),应该能打印出来Sender发生的信息;同时HTTP页面里的message_queue的Dept(Bytes)应该为0。


至此,一个简单的Qpid应用就搭建成功了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章