ActiveMQ Jolokia API How can I get full message text

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 text of the message?

This I tested:

Receive: 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'

      

With the message:

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

      

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

      

Mistake: java.lang.NumberFormatException : For input string: "content"

The only way I can 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'"],
}

      

But then I only get the first 500 characters

thanks for the help

+3


source to share


2 answers


works for me and does not affect the state of the queue, which was the target:



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

      

+1


source


Based on the comments, leaving this as an answer for you.

The Jolokia API is a management API, not a message consuming API. The ActiveMQ project provides a REST API bound to /api/message

for users to work with.

Full details of the API can be found here: http://activemq.apache.org/rest.html



Suppose you have a queue named "ERRORS" and ActiveMQ is running by default. You can POST

to this url: http://localhost:8161/api/message/ERRORS?type=queue

add a post. Please view their documents in full format. Then you can read messages from that queue by executing GET

at the same address:http://localhost:8161/api/message/ERRORS?type=queue

By default, you need to pass authentication information for each operation.

-1


source







All Articles