cURL and ActiveMQ
I need an example on how to read/write to an ActiveMQ queue over HTTP in C or C++ using cURL (or something else, I'm open to anything at this point). I have working code in C#, but it doesn't help. Any help is appreciated, Thank you.开发者_如何学JAVA
First I assume:
- You are running activemq 5.5.0
- You are using the default activemq configuration that enables the web-console
- Test it by pointing a browser to http://localhost:8161/admin
- By cURL you mean libcurl and a command line example is sufficient
Example:
- Create a queue named test, set the body to hello world.
- Note: [clientId] this a unique string to identify your subscribe otherwise a new consumer will be created for each request see REST
$ curl -d 'body="Hello World"' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
- Pop the message of the queue
$ curl -X delete "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
- You should see
"Hello World"
- Finally unsubscribe from the queue
$ curl -d 'action=unsubscribe' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
You should be able to monitor all of the above operations from the admin interface
Until version 5.8, REST API was part of the Web Samples and was mapped to http://localhost:8161/demo/message url. From 5.8 onwards, the API is available by default at http://localhost:8161/api/message url
http://activemq.apache.org/rest.html
精彩评论