[rabbitmq-discuss] RabbitMQ HTTP interface

Tony Garnock-Jones tonyg at lshift.net
Thu Apr 30 18:18:55 BST 2009


lenz wrote:
> from the javascript client that comes with the rabbit-http2 repo i kind
> of got an idea how things are supposed to work but i wanted to ask if
> there is some sort of documentation/API description around that i could
> use to implement a client from?

I can think of a few things to get you started -- and BTW this sounds
like a really interesting project, do keep us up-to-date with your
progress as you go!

1. The service is standard JSON-RPC 1.1 (see spec mirrored here:
You can probably use an off-the-shelf JSON-RPC client library.

2. There is plenty of documentation on the Erlang JSON-RPC service that
the RabbitMQ HTTP2 adapter uses here:

3. The service descriptions (see the JSON-RPC 1.1 spec, §10) are as follows:

* The channel factory at .../rpc/rabbitmq:


* Each individual channel, at .../rpc/SOMEUNGUESSABLEHEXIDENTIFIER:



The "poll" method returns details of all the asynchronous events that
have arrived for the channel -- the basic.delivers, the basic.returns.

The "close" method is used to shut down the channel.

The "call" and "cast" methods are used to perform synchronous (e.g.
exchange.declare) and asynchronous (e.g. basic.publish, basic.ack) AMQP
operations, respectively.

"call" returns the response to the synchronous call.

"cast" returns a list of asynchronous events that had been queued up at
the server-side of the Channel, *just like poll does*. So both poll and
cast can return deliveries intended for your program!

See rabbitmq.js's definitions of such as basicPublish() and
exchangeDeclare() for examples of usage.

Here's a login call (to .../rpc/rabbitmq):



Then, in the URL you're using to access the channel-opening service
(i.e. .../rpc/rabbitmq), replace "rabbitmq" with the "service" result
parameter, yielding .../rpc/SOMEUNGUESSABLEHEXIDENTIFIER. This is the
URL for your channel object. You use this to begin subscriptions and
issue AMQP commands.

Here's a queue declaration:



Here's a use of "cast":

"hello, world",


Note how the "result" array is non-empty, and that RabbitMQ is quick
enough that by the time the JSON-RPC object is ready to return to its
caller, the method that was just published has already been delivered :-)

Generally, for method arguments, follow the definitions given in the 0-8
json document:

Hopefully that is enough to get you started!

 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: tonyg at lshift.net

More information about the rabbitmq-discuss mailing list