admin管理员组

文章数量:1301611

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 onplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379 }

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 onplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379 }
Share edited Jul 29, 2022 at 21:27 ggorlen 57.4k8 gold badges110 silver badges154 bronze badges asked Jul 14, 2020 at 17:57 user13459552user13459552
Add a ment  | 

1 Answer 1

Reset to default 8

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.

本文标签: javascriptBull without Redis for queue managementStack Overflow