ActiveMQ implements a REST-ful API to messaging which allows any web capable device to publish or consume messages using a regular HTTP POST or GET.

If you are working with DHTML or web browsers you might wanna check out our Ajax support or try running the REST examples

Mapping of REST to JMS

To publish a message use a HTTP POST. To consume a message use HTTP DELETE or GET.

ActiveMQ has a Servlet that takes care of the integration between HTTP and the ActiveMQ dispatcher.

You can map a URI to the servlet and then use the relative part of the URI as the topic or queue name. e.g. you could HTTP POST to

http://www.acme.com/queue/orders/input

which would publish the contents of the HTTP POST to the orders.input queue on JMS.

Similarly you could perform a HTTP DELETE GET on the above URL to read from the same queue. In this case we will map the MessageServlet from ActiveMQ to the URI

http://www.acme.com/queue

and configure it to accept the URI as a queue destination. We can do similar things to support topic destinations too.

We can use the HTTP session to denote a unique publisher or consumer.

Note that strict REST requires that GET be a read only operation; so strictly speaking we should not use GET to allow folks to consume messages. Though we allow this as it simplifies HTTP/DHTML/Ajax integration somewhat.

For a more cleaner mapping of a simple transfer protocol to different languages, you might wanna take a look at Stomp.

Timeouts

When reading from a queue we might not have any messages. We can use a timeout query parameter to indicate how long we are prepared to wait for a message to arrive. This allows us to poll or block until a message arrives.

Couple this with HTTP 1.1 keep-alive sockets and pipeline processing we can have efficient access to JMS over HTTP.

Obviously if your client is Java then using ActiveMQ's JMS API is the fastest and most efficient way to work with the message broker; however, if you are not using Java or prefer the simplicity of HTTP then it should be fairly efficient, especially if your HTTP client supports keep-alive sockets and pipeline processing.

Graphic Design By Hiram