protocol7 archive
13 June 2007

A RESTful queue

As messaging and therefore queues is close to my heart, I’ve been following the discussions on rest-discuss on how to construct a RESTful queue with great interest. The discussion started (as did my thinking on the topic a year or so back) around how ActiveMQ has choosen to implement their REST support, a somewhat broken model as pointed out by Paul Winkler (e.g. non-safe GET, DELETE on queue deletes message rather than the queue).

My favorite model so far is the one suggested by Steve Bjorg, also quite similar to the one described in HTTPLR. In that case you would push messages onto a queue with POST and pop then with a combination of POST and DELETE. To quote from Steve’s email.

To add an item:
POST /queue
Content-Type: application/xml (or whatever a queue item is)
–>
201 Created
Location: http://server.com/queue/itemXYZ

To request to pop an item:
POST /queue
Content-Type: application/w-www-form-urlencoded
AckTTL=60 (where AckTTL is the time to acknowledge the queue item or
it becomes available again)
–>
200 Ok
http://server.com/queue/itemABC

To delete a popped item:
DELETE /queue/itemABC

Go read the discussion thread as it contains many interesting aspects on this pretty hard problem. Ideas on how to improve the current suggestions is very welcome.

tags: Messaging/JMS