About

Kamaloka-js is an implementation of the AMQP messaging protocol in native JavaScript. It is setup to be used with Orbited but can be used with any library which produce TCPSockets in the browser similar to Orbited. Kamaloka bindings are generated from qpid XML protocol description files.

Status

You can currently :

  • negotiate a connection with an AMQP 0.10 server (support for adding and loading different versions is there if a new spec comes along)
  • issue any commands and controls described by the spec (whether or not the server is doing anything with them has not been verified yet but, it doesn’t drop your connection)

Some limitation:

  • for now we don’t handle multiple frames or channels though this feature is planned down the road
  • we don’t do automatic version negotiation, but then we only implement one version

Why Kamaloka

amqp-js was taken by a project that implements the 0-8 AMQP protocol through Flash. If some day the qpid project wanted to use kamaloka-js as the definitive AMQP javascript implementation I would be happy to rename it qpid-js, but I am not that presumptuous. The thought process for the name went like this:

qpid->cupid->kama->kamaloka

Since Kama is in the same lexicon as Moksha (another project I work on which will be using the bindings) I thought it fit nice. It also allows me to name the QMF bindings kamarupa-js since according to the wikipedia Kama page “Kama-rupa is a subtle body or aura composed of desire, while Kama-loka is the realm this inhabits.” So QMF inhabits AMQP :)

Playground

Included in the distribution is a playground for testing the bindings in interesting AMQP configurations on your local machine. As pieces get implemented the playground will expand to show off different ways of using the bindings. Bellow is an example of using the current low level bindings based off the python subscribe example:


<script type="text/JavaScript">
   Orbited.settings.port = 9000;
   amqp_broker_port = 7000;

   amqp_conn = amqp.Connection({host: 'localhost',
                                port: amqp_broker_port,
                                send_hook: function(msg) { // for debugging
                                                       append_msg('SENT', msg);
                                                  },
                                recive_hook: function(data) { // for debugging
                                                        append_msg('RECV', data);
                                                    }
                             });
    amqp_conn.start();

    // You should have your server generate a UUID since browser methods
    // are unreliable at best
    session = amqp_conn.create_session('not_a_great_id' + (new Date().getTime() + Math.random()));

    var fedoraproject = "org.fedoraproject-" + session.name;
    session.Queue('declare', {queue:fedoraproject, exclusive:true});
    session.Exchange('bind', {exchange: "amq.topic",
                              queue: fedoraproject,
                              binding_key: "org.fedoraproject.#"});

    // Bind each queue to the control queue so we know when to stop
    session.Exchange('bind', {exchange:"amq.topic",
                              queue: fedoraproject,
                              binding_key:"control"});
</script>

Give me the code

[read this post in: ar de es fr it ja ko pt ru zh-CN ]