How to use the queue.Consumer.createStdConfig 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
process.env.AWS_XRAY_DEBUG_MODE=1;

const Consumer = require('queue').Consumer;
const Database = require('@subfuzion/database').Database;
const xray = require('aws-xray-sdk-core');

// set queue connection timeout to 0 since we want the worker queue
// consumer to block indefinitely while waiting for messages
let queueConfig = Consumer.createStdConfig({ timeout: 0 });
let databaseConfig = Database.createStdConfig();

let consumer, db, quitting = false;

// Set up signal handlers and open connections to database and queue.
async function init() {
  // Handle SIGTERM and SIGINT (ctrl-c) gracefully
  process.on('SIGTERM', async () => {
    console.log('worker received SIGTERM');
    // if already quitting then force quit
    if (quitting) {
      console.log('forcing quit now');
      process.exit();
    }
    await quit();
  });