index.js
function readQueue() {
        disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
            if(err) {
                self.emit('error', err);
            }
            else {
                jobs.forEach(function(job) {
                    pendingMessages++;
                    self.emit('job', job, function() {
                        pendingMessages--;
                        if(!self.paused && concurrencyPaused && pendingMessages < self.concurrency) {
                            concurrencyPaused = false;
                            setImmediate(readQueue);
                        }
                    });
                });

                if(!self.paused && pendingMessages<self.concurrency) {
                    setImmediate(readQueue);
                }
                else {
                    concurrencyPaused = true;
                }
            }
        });
    }
function readQueue() {
        disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
            if(err) {
                self.emit('error', err);
            }
            else {
                jobs.forEach(function(job) {
                    pendingMessages++;
                    self.emit('job', job, function() {
                        pendingMessages--;
                        if(!self.paused && concurrencyPaused && pendingMessages < self.concurrency) {
                            concurrencyPaused = false;
                            setImmediate(readQueue);
                        }
                    });
                });

                if(!self.paused && pendingMessages<self.concurrency) {
                    setImmediate(readQueue);
                }
                else {
                    concurrencyPaused = true;
                }
            }
        });
    }
function readQueue ( ) { disq . getJob ( { queue : queueName , count : self . jobCount , withcounters : self . withCounters } , function ( err , jobs ) { if ( err ) { self . emit ( 'error' , err ) ; } else { jobs . forEach ( function ( job ) { pendingMessages ++ ; self . emit ( 'job' , job , function ( ) { pendingMessages -- ; if ( ! self . paused && concurrencyPaused && pendingMessages < self . concurrency ) { concurrencyPaused = false ; setImmediate ( readQueue ) ; } } ) ; } ) ; if ( ! self . paused && pendingMessages < self . concurrency ) { setImmediate ( readQueue ) ; } else { concurrencyPaused = true ; } } } ) ; }
Main message processor
Main message processor