gpt4 book ai didi

java - ActiveMQ Jolokia API 如何获取完整的消息正文

转载 作者:行者123 更新时间:2023-12-02 08:56:15 29 4
gpt4 key购买 nike

我想编写自己的 ActiveMQ 监视器。我可以从队列中获取队列和消息。但消息正文(内容)很短。我怎样才能获得完整的消息正文?

我已经测试过:

获取:总是错误

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'

带帖子:

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'"],
}

错误:java.lang.OutOfMemoryError:Java堆空间

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"
}

错误:java.lang.NumberFormatException:对于输入字符串:“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'"],
}

但是我只得到前 500 个字符

感谢您的帮助

最佳答案

对我有用并且不会影响队列状态,这是一个目标:

#! /bin/bash

url="http://localhost:8161/api/jolokia/?maxDepth=10&maxCollectionSize=1000&ignoreErrors=true"
u='admin:admin'

q='orders.input'
m="org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=$q"

l="curl.log"

s='"operation":"browseMessages()"'
d='{"type":"exec", "mbean":"'"$m"'", '"$s"'}'
jq='[.value[].jMSMessageID]'
sed="s/^ \"ID:([a-zA-Z0-9_:-]{10,})\",?$/\1/p"
ids="`curl -u \"$u\" --stderr \"$l\" -d \"$d\" \"$url\" |jq \"$jq\" |sed -rn \"$sed\"`"

jq='[{"time": .value.JMSTimestamp, "id": .value.JMSMessageID, "msg": .value.Text}]'
d="{\"type\":\"exec\", \"mbean\":\"$m\", \"operation\":\"getMessage(java.lang.String)\", \"arguments\":[\"ID:X\"]}"
echo "$ids" |xargs -iX curl -u "$u" --stderr "$l" -d "$d" "$url" |jq "$jq"

关于java - ActiveMQ Jolokia API 如何获取完整的消息正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27707190/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com