How to use the queue.Consumer function in queue

To help you get started, we’ve selected a few queue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-samples / voteapp / src / worker / main.js View on Github external
// if already quitting then force quit
    if (quitting) {
      console.log('forcing quit now');
      process.exit();
    }
    await quit();
  });

  try {
    console.log('worker initializing');

    db = new Database(databaseConfig);
    await db.connect();
    console.log('connected to database');

    consumer = new Consumer('queue', queueConfig);
    consumer.on('error', err => {
      console.log(err.message);
      process.exit(1);
    });
    await new Promise(resolve => {
      consumer.on('ready', async() => {
        resolve();
      });
    });
    console.log('connected to queue');

    console.log('worker initialized');
  } catch (err) {
    console.log(err);
    process.exit(1);
  }