Bull without Redis for queue management

Viewed 1824

Is it possible to use Bull (for job management) without using Redis?

My code:

@Injectable()
export class MailService {
    private queue: Bull.Queue;
    private readonly queueName = 'mail';

    constructor() {
        this.queue = new Bull(this.queueName)
    }

    addTaskToQueue() {
        this.queue.process('send_mail',
            async (job: Bull.Job, done: Bull.DoneCallback) => {
                console.log('Send mail!');
                console.log(JSON.stringify(job.data));

                done();
            })
    }

    async send(year: number, month: number) {
        try{
            await this.queue.add('send_mail', {
                year,
                month
            });
            console.log('done');
        } catch(err){
            console.log(err);
        }

    }
}

Upon running, my console trew this error:

{ Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379 }
1 Answers

Bull is built on top of Redis, that's its backend. You can't use it without Redis. You could probably implement some sort of custom system that doesn't require something like Redis using RxJS and some state management, but Bull must have Redis.

Related