/activemq-rest

REST wrapper for ActiveMQ.

Primary LanguageJava

ActiveMQ REST

REST wrapper for ActiveMQ.

Requirements

Building the example

$ cd $PROJECT_ROOT
$ mvn clean install

Running the example

Open a terminal window and start the controller.

$ cd $PROJECT_ROOT/activemq-rest-controller
$ mvn camel:run

Open a terminal window and start the sample consumer A.

$ cd $PROJECT_ROOT/activemq-rest-consumer-a
$ mvn camel:run

Open a terminal window and start the sample consumer B.

$ cd $PROJECT_ROOT/activemq-rest-consumer-b
$ mvn camel:run

All interaction with the controller (ie, managing subscriptions, publishing messages, ...) can be done using simple REST calls. So you can, for example, use something as simple as curl. Here are some example commands:

Register subscriber:

$ curl -X POST -H 'Content-Type: application/json' -d '{"url":"http://localhost:8081"}' 'http://localhost:9090/subscriptions/A/TEST.FOO'

Register subscriber with selector:

$ curl -X POST -H 'Content-Type: application/json' -d '{"selector":"foo = '"'"'bar'"'"'","url":"http://localhost:8081"}' 'http://localhost:9090/subscriptions/A/TEST.FOO'

Delete subscriber:

$ curl -X DELETE -H 'Content-Type: application/json' 'http://localhost:9090/subscriptions/A/TEST.FOO'

Get subscription info:

$ curl -X GET -H 'Content-Type: application/json' 'http://localhost:9090/subscriptions/A/TEST.FOO'

Get subscription info (all):

$ curl -X GET -H 'Content-Type: application/json' 'http://localhost:9090/subscriptions/A'

Publish a message:

$ curl -X POST -H 'Content-Type: application/json' -d '{"headers":{"foo": "bar"},"body":"Hello World!"}' 'http://localhost:8080/messages/TEST.FOO'

Load testing

Note: This is a JMS-like implementation over REST. The HTTP protocol was not meant for messaging (since it has to constantly open/close connections). So don't expect the performance you would get with a native JMS messaging solution (ie, using A-MQ directly via a protocol like OpenWire).

Because this is a REST implementation, you can use any HTTP load testing tool that you'd like. If you don't have a favorite, there is a sample Gatling [http://gatling.io/] test located in the $PROJECT_ROOT/activemq-rest-jaxrs-api/src/test/gatling folder.