Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #892
Closed
Open
Issue created Mar 19, 2018 by Administrator@rootContributor

Process only 1 job using queue.process

Created by: cbjuan

Hi

Rather than an issue, this is a question about Bull. I'm coding a queues system where I don't need to process the queue in a continuous way (like it does queue.process()) but I need retrieve only one job each time I want (instead of processing every job available).

I tried to do this using process by this way:

const consumeJob = function(queue) {
  return new Promise(
    function(resolve, reject){
          queue.isReady().then(() =>{
            queue.process(function(job){ 
              queue.close();
              resolve(job);
            });
          })
          .catch(function(error){
            reject(error);
          });
    }
  );
};

In this case, using queue.close() I destroy the Redis connection, so if I want to retrieve other job (or continue operating using Bull) without reinitiating the script (or Node server) I get the error Error: Connection is closed. Knowing that, I would like to ask:

  • If there is another way of obtaining only 1 (or N) job(s) using the queue.process method.
  • Is it possible to reconnect Redis after the queue.close() to continue using bull in other functions and parts of my code?

Thanks in advance

Assignee
Assign to
Time tracking