1

I'm working to get my kue workers set up and have discovered something strange. If I create my queue using the default kue redis connection everything works perfectly:

var kue = require('kue')
    , redis = require('redis');

var q = kue.createQueue();

q.process('cypher', function(job, done){});

The worker starts up perfectly. However, if I try to override the default redis connection with one of my own I get a

Error: Connection in subscriber mode, only subscriber commands may be used

when execution hits the q.process function below:

var kue = require('kue')
    , redis = require('redis');


var redisClient =   redis.createClient();

var q = kue.createQueue({
    redis: {
        createClientFactory: function(){

            return redisClient;
        }
    }
});

q.process('cypher', function(job, done){});

It doesn't seem to any sense. I thought maybe I was committing a classic async error, but even the following was I get the same error. Any insights?

redisClient.on('connect', function () {
    console.log('gotten here!!!');
    var q = kue.createQueue({
        redis: {
            createClientFactory: function(){

                return redisClient;
            }
        }
    });

    q.process('cypher', function(job, done){});
});
Robert Moskal
  • 21,737
  • 8
  • 62
  • 86

1 Answers1

2

you are not actually passing a new client each time when your factory method is called. Returning a singleton instance from createClientFactory makes kue to use the same connection for commands and pub/sub and this is not possible in redis connection modes

Behrad
  • 46
  • 2
  • I should have known from the name: createClientFactory and the fact that it takes a function. Nonetheless it wasn't absolutely clear from the docs. Perhaps this question will save someone a bit of time! – Robert Moskal Jun 19 '15 at 23:07