seebees/ironmq — Issue #2: concurrent operations
Author: bbn
Created: 2012-02-07 19:11:52+00:00
State: open

The below code is a test to try and send 10 concurrent operations to an ironmq queue. When I run it I observe that the operations happen in fairly regular sequence, as if only one at a time is being executed.

I wondered if perhaps this was a limitation of ironmq. But if I fire up multiple terminal windows I can execute this code in many different windows simultaneously, and none of them slow down. So the limitation appears to be within one single process.

Is there a way to modify this module so that concurrent operations are supported?

(function() {
var sendReceiveDelete;
var ironmq = require("ironmq");

process.env.IRON_MQ_TOKEN = '...';

process.env.IRON_MQ_PROJECT_ID = '...';

sendReceiveDelete = function() {
var mq, msg;
mq = ironmq(process.env.IRON_MQ_TOKEN);
mq = mq.projects(process.env.IRON_MQ_PROJECT_ID);
mq = mq.queues('test');
msg = "My lucky number is " + (Math.floor(Math.random() * 100000000)) + ".";

mq.put(msg, function(err, result) {
console.log("SEND: " + (JSON.stringify(result)));

mq.get(function(err, result) {
console.log("RECEIVE: " + (JSON.stringify(result)));

if (result.length > 0) {
mq.del(result[0].id, function(err, result) {
return console.log("DELETE: " + (JSON.stringify(result)));
});

}

process.nextTick(sendReceiveDelete);
});

});
};

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

sendReceiveDelete();

}).call(this);