Jboss
從 Jboss 應用程序伺服器控制台使用 Curl 讀取 JMS 隊列消息計數
我正在使用 Jboss Application Server 7.1.3 Final,我的要求是如果特定 jms 隊列在隊列中有超過 n 條消息,則提醒管理員採取必要的措施。如果我得到預期的 json 結果,我可以通過 shell 腳本完成。
我嘗試了以下命令
curl --digest -D - http://user:userpwd@localhost:9990/management/ --header "Content-Type: application/json" -d '{"operation":"read-resource", "address":["subsystem","messaging","hornetq-server","jms-destinations","jms-queue"], "json.pretty":1}'
並獲得以下輸出
HTTP/1.1 401 Unauthorized Content-length: 0 Www-authenticate: Digest realm="ManagementRealm",nonce="22087e300bd9a2a53c37f21bdefe1950" Date: Mon, 31 Aug 2015 13:02:47 GMT HTTP/1.1 500 Internal Server Error Transfer-encoding: chunked Content-type: application/json Date: Mon, 31 Aug 2015 13:02:47 GMT { "outcome" : "failed", "failure-description" : "JBAS014807: Management resource '[\n (\"subsystem\" => \"messaging\"),\n (\"hornetq-server\" => \"jms-destinations\")\n]' not found", "rolled-back" : true }
我的消息傳遞的 Standalone-full.xml 配置:
<subsystem xmlns="urn:jboss:domain:messaging:1.2"> <hornetq-server> <jms-destinations> <jms-queue name="myQueue"> <entry name="queue/myQueue"/> </jms-queue> </jms-destinations> </hornetq-server> </subsystem>
(刪除了其餘的standalone-full.xml 配置)
curl命令中需要添加什麼嗎?
嘗試:
# curl -i --digest "http://user:****@localhost:9990/management/subsystem/messaging/hornetq-server/default/jms-queue/myQueue?operation=resource&recursive&include-runtime&json.pretty"
結果
HTTP/1.1 200 OK Transfer-encoding: chunked Content-type: application/json Date: Mon, 31 Aug 2015 14:36:03 GMT { "consumer-count" : 1, "dead-letter-address" : "jms.queue.DLQ", "delivering-count" : 0, "durable" : true, "entries" : [ "queue/myQueue", "java:jboss/exported/jms/queue/myQueue" ], "expiry-address" : "jms.queue.ExpiryQueue", "message-count" : 0, "messages-added" : 0, "paused" : false, "queue-address" : "jms.queue.myQueue", "scheduled-count" : 0, "selector" : null, "temporary" : false }
或者
curl -i --digest 'http://user:*****@localhost:9990/management' --header "Content-Type: application/json" \ -d '{"operation":"read-resource", "recursive":"true", "include-runtime":"true", "address":["subsystem", "messaging", "hornetq-server", "default", "jms-queue", "myQueue"], "json.pretty":1}'
結果:
HTTP/1.1 200 OK Transfer-encoding: chunked Content-type: application/json Date: Mon, 31 Aug 2015 14:36:03 GMT { "outcome" : "success", "result" : { "consumer-count" : 1, "dead-letter-address" : "jms.queue.DLQ", "delivering-count" : 0, "durable" : true, "entries" : [ "queue/myQueue", "java:jboss/exported/jms/queue/myQueue" ], "expiry-address" : "jms.queue.ExpiryQueue", "message-count" : 0, "messages-added" : 0, "paused" : false, "queue-address" : "jms.queue.myQueue", "scheduled-count" : 0, "selector" : null, "temporary" : false } }