ActiveMQ Jolokia API如何获得完整的消息正文 [英] ActiveMQ Jolokia API How can I get the full Message Body

查看:493
本文介绍了ActiveMQ Jolokia API如何获得完整的消息正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写自己的ActiveMQ Monitor。我可以从队列中获取队列和消息。但是消息正文(内容)被缩短了。如何获得完整的消息正文?

I want to write my own ActiveMQ Monitor. I can get Queues and Messages from a Queue. But the Message Body (content) is shorted. How can I get the full Message Body?

我已经测试过:

获取:总是错误

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

我可以工作的唯一方法是每个帖子:

The only way i can i work is per Post:

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个Chars

But then I get only the first 500 Chars

谢谢您的帮助

推荐答案

为我和不会影响队列状态,这是一个目标。

works for me and doesn't impact the queue state, which was a goal:

#! /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"

这篇关于ActiveMQ Jolokia API如何获得完整的消息正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆