Reading the docs at http://activemq.apache.org/ I noticed they have a
REST API. So I clicked on http://activemq.apache.org/rest.html to
read more and, perhaps not surprisingly, found that it's pretty broken
REST.
Adding a message to the queue seems fine... they give as an example
a queue at http://www.acme.com/queue/orders/input and you can add a
new message in the queue by POSTing to that URL. Fine.
Consuming a message from the queue, though, seems problematic.
They allow either GET or DELETE on the *same* URL to pop a message
from the queue.
They are aware that this is wrong:
"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."
... but they don't seem to understand *how* wrong it is:
* it's not REST that says GET is a read-only operation; it's HTTP. So
their HTTP implementation is broken. Sadly seems to be pretty common.
* DELETE on a URL representing a queue means you want to delete the
entire queue, not a single message!
The reason I'm writing to this list is that I thought it was an
interesting case and I couldn't immediately think of better solution.
Has anybody thought of a good way to model a queue?
You could of course do a GET on the queue, returning a list of
available messages, then DELETE one of those - but that leads to
concurrency problems.
--
Paul Winkler
http://www.slinkp.com