Bur*_*ner 5 java activemq-classic jmx jolokia
我想编写自己的 ActiveMQ 监视器。我可以从队列中获取队列和消息。但是消息体(内容)是短的。如何获得完整的消息正文?
这是我测试过的:
得到: Always errors
http://localhost:8161/api/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=errors/browseMessages(java.lang.String)/JMSMessageID%3D%27ID%3AW530-62766-1419849619826-0%3A15%3A1%3A1%3A1%27
http://localhost:8161/api/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=errors/browseMessages(java.lang.String)/JMSMessageID='ID:W530-62766-1419849619826-0:15:1:1:1'
Run Code Online (Sandbox Code Playgroud)
与邮政:
http://localhost:8161/api/jolokia/?ignoreErrors=true&canonicalNaming=false
{
"type":"exec",
"mbean":"org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=errors",
"operation":"browseMessages(java.lang.String)",
"arguments":["JMSMessageID='ID:W530-62766-1419849619826-0:15:1:1:1'"],
}
Run Code Online (Sandbox Code Playgroud)
错误: java.lang.OutOfMemoryError: Java heap space
http://localhost:8161/api/jolokia/?ignoreErrors=true&canonicalNaming=false
{
"type":"exec",
"mbean":"org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=errors",
"operation":"browseMessages(java.lang.String)",
"arguments":["JMSMessageID='ID:W530-62766-1419849619826-0:15:1:1:1'"],
"path":"content"
}
Run Code Online (Sandbox Code Playgroud)
错误: java.lang.NumberFormatException : For input string: "content"
我可以工作的唯一方法是每个帖子:
http://localhost:8161/api/jolokia/?maxDepth=7&maxCollectionSize=500&ignoreErrors=true&canonicalNaming=false
{
"type":"exec",
"mbean":"org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=errors",
"operation":"browseMessages(java.lang.String)",
"arguments":["JMSMessageID='ID:W530-62766-1419849619826-0:15:1:1:1'"],
}
Run Code Online (Sandbox Code Playgroud)
但后来我只得到前 500 个字符
感谢您的帮助
Joh*_*ent -1
根据评论,将其作为答案留给您。
Jolokia API 是管理 API,而不是消息消费 API。ActiveMQ 项目提供了一个绑定的 REST API 供/api/message用户使用。
完整的 API 详细信息可以在这里找到: http: //activemq.apache.org/rest.html
假设您有一个名为“ERRORS”的队列,并且 ActiveMQ 在默认配置上运行。您可以POST向此 URL:http://localhost:8161/api/message/ERRORS?type=queue添加消息。请参阅他们的文档了解完整格式。然后,您可以通过在同一 URL 上执行 a 操作来从此队列中读取消息GET:http://localhost:8161/api/message/ERRORS?type=queue
默认情况下,您需要为每个操作传递身份验证信息。