Tuesday, September 8th, 2009
Kamaloka: AMQP implementation in JS
Would you like to talk messaging directly from the browser? Kamaloka is a new library that speaks AMQP. You can easily tie to Orbited but also, in theory, any other library that speaks TCPSockets.
- 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"});





2.9 rating from 19 votes
xmlsockets, wow.