I am using RabbitMQ to process some jobs in my project. Currently the if i send 5 jobs, lets say
Job1
Job2
Job3
Job4
Job5
All the jobs get delivered to the queue, but if Job1 takes 5 seconds to complete and Job2 takes 2 seconds to complete, the order of execution becomes like
Job5
Job1 etc.,
Is there a way for me to make it so that all these jobs get executed only after the previous one gets completed (Execution flow like Job1, Job2, Job3, Job4, Job5) in RabbitMQ receiver?
Job Execution (as requested by Dave)
var amqp = require('amqplib');
amqp.connect('amqp://localhost').then(function(conn) {
process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(ch) {
var ok = ch.assertQueue('hello', {durable: false});
ok = ok.then(function(_qok) {
return ch.consume('hello', function(msg) {
//JOB HERE
}, {noAck: true});
});
return ok.then(function(_consumeOk) {
console.log(' [*] Waiting for messages. To exit press CTRL+C');
});
});
}).then(null, console.warn);
thanks, Balan