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應用就搭建成功了。