Invoke sendTextMessage using Jolokia api

classic Classic list List threaded Threaded
3 messages Options
skiarn skiarn
Reply | Threaded
Open this post in threaded view
|

Invoke sendTextMessage using Jolokia api

Hello!
First I must say, Jolokia is really nice! I'm using it with RHEL activemq 6.1.

I'm trying to use the jmx api,

I like to call this function:
sendTextMessage(Map<?,?> headers, String body, String user, String password)
see: http://activemq.apache.org/maven/apidocs/org/apache/activemq/broker/jmx/DestinationViewMBean.html



But I'm missing something.. when I execute I get a java.lang.IllegalArgumentException : Invalid JSON request java.io.InputStreamReader...

I'm doing something wrong, can anyone give me pointers what i'm doing wrong?

My http POST:
http://localhost:8181/hawtio/jolokia/exec/org.apache.activemq:type=Broker,brokerName=amq,destinationType=Queue,destinationName=DUMMY.QUEUE/sendTextMessage(java.util.Map,java.lang.String,java.lang.String,java.lang.String)/{"headers": [{"dummyheader1": "hello"},{"dummyheader2": "world"}]},hellew message,admin,admin

I want to send a message to Queue: DUMMY.QUEUE.
Message headers should be: dummyheader1=hello, dummyheader2=world
Message body = hellew message
User credentials, username=admin, password = admin

Thanks for reply!
Happy
skiarn skiarn
Reply | Threaded
Open this post in threaded view
|

Re: Invoke sendTextMessage using Jolokia api

I figured it out! :)
If someone else wants a working example, see below!

Url: http://localhost:8181/hawtio/jolokia
Post payload:

{
   "type":"EXEC",
   "mbean":"org.apache.activemq:type=Broker,brokerName=amq,destinationType=Queue,destinationName=DUMMY.QUEUE",
   "operation":"sendTextMessage(java.util.Map,java.lang.String,java.lang.String,java.lang.String)",
   "arguments":[{"headers": [{"dummyheader1": "hello"},{"dummyheader2": "world"}]}, "hello world message","admin", "admin"]
}

Remember to set:
SetBasicAuth.

roland roland
Reply | Threaded
Open this post in threaded view
|

Re: Invoke sendTextMessage using Jolokia api

Cool, thanks for sharing !
... roland