Code Monkey home page Code Monkey logo

Comments (2)

srijan17 avatar srijan17 commented on September 22, 2024

i have the same issue, trying to run agenda so pipelines are processed in sequential manner (concurrency 1 )
if i bombard it with request it starts skipping files and keeping them at 'Queued ' state .

did you find a solution ?

from agenda.

Minozzzi avatar Minozzzi commented on September 22, 2024

Yes, I found it, in my case using Nestjs I abstracted a global service from the Agenda, it turns out that the order in which nestjs initialized the modules it tried to register the queue before creating the global module, what I did was remove the global module and import as a dependency on the modules that use my agenda module. My agenda module is basically a initializer

I removed the global here

import { Module } from '@nestjs/common';
import { AgendaService } from './agenda.service';

@Module({
  providers: [AgendaService],
  exports: [AgendaService],
})
export class AgendaModule {}
import { Injectable, OnModuleInit } from '@nestjs/common';
import { Agenda, Job } from 'agenda';

export interface JobDefinition {
  name: string;
  handler: (job: Job) => Promise<void>;
}

@Injectable()
export class AgendaService implements OnModuleInit {
  private agenda: Agenda;

  async onModuleInit() {
    this.agenda = new Agenda({
      db: {
        address:
          'mongodb+srv://root:[email protected]/?retryWrites=true&w=majority&appName=reload-api',
        collection: 'agendaJobs',
      },
    });

    await new Promise<void>((resolve, reject) => {
      this.agenda.on('ready', () => {
        resolve();
      });

      this.agenda.on('error', (error) => {
        console.error('Erro ao inicializar agenda:', error);
        reject(error);
      });
    });

    await this.agenda.start();
  }

  getAgenda(): Agenda {
    return this.agenda;
  }
}

from agenda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.