Skip to content

Queue.id

Grant Carthew edited this page Sep 27, 2016 · 11 revisions

Property Details

Usage: Read Only

Get: String

  • Returns a complex id string used to identify the Queue object process.

Example:

const Queue = require('rethinkdb-job-queue')
const q = new Queue()
let id = q.id
// As an example the id will be similar to this
// id === 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:11797:2ff3db65-ffef-4a9b-a932-b6ac8bcc48a0'

Description

The Queue object id property is a very important value for internal use within rethinkdb-job-queue.

From a consumers point of view, you probably will not need the Queue.id unless something is going wrong with your job processing. If there is something going wrong you can use the Queue.id to determine which Queue object made changes to the job in the queue.

The id value is created from the following colon separated information.

  • Server Name
  • Database Name
  • Table or Queue Name
  • Node.js Process Id
  • Generated UUID

During job updates to the queue database table the Queue.id is recorded against the Job.queueId property. Also every time a Job log entry is added to a job in the database, the Queue.id is added to the log entry.

One of the ways the Queue.id is used internally is to determine if queue changes, via the RethinkDB changeFeed, have been made by the local Queue object or not. By doing this each Queue object within your code will raise events for the whole queue rather than just local events.

See the Queue Events document for more detail.

Below is an example of a job from the database with log history. Note that this example was taken from the queue process tests and all changes have been made from the same Queue object. Therefore the Queue.id value is the same throughout.

In a complex queue with multiple Queue objects distributed between different hosts, expect the Queue.id values in a similar job to be different between the log entries.

{ dateCreated: 2016-08-17T03:44:30.634Z,
  dateFinished: 2016-08-17T03:44:42.123Z,
  dateEnable: 2016-08-17T03:44:48.086Z,
  dateStarted: 2016-08-17T03:44:41.086Z,
  id: '0e4a717c-84b1-43f3-98dd-2e670ebc28f9',
  log:
  [ { date: 2016-08-17T03:44:30.634Z,
      message: 'Job added to the queue',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 0,
      status: 'waiting',
      type: 'information' },
    { date: 2016-08-17T03:44:30.672Z,
      message: 'Job retrieved and active',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 0,
      status: 'active',
      type: 'information' },
    { date: 2016-08-17T03:44:31.728Z,
      duration: 1056,
      message: 'Job timed out (run time > 1 sec)',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 1,
      status: 'failed',
      type: 'warning' },
    { date: 2016-08-17T03:44:31.746Z,
      message: 'Job retrieved and active',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 1,
      status: 'active',
      type: 'information' },
    { date: 2016-08-17T03:44:32.765Z,
      duration: 1018,
      message: 'Job timed out (run time > 1 sec)',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 2,
      status: 'failed',
      type: 'warning' },
    { date: 2016-08-17T03:44:35.883Z,
      message: 'Job retrieved and active',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 2,
      status: 'active',
      type: 'information' },
    { date: 2016-08-17T03:44:36.904Z,
      duration: 1021,
      message: 'Job timed out (run time > 1 sec)',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 3,
      status: 'failed',
      type: 'warning' },
    { date: 2016-08-17T03:44:41.086Z,
      message: 'Job retrieved and active',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 3,
      status: 'active',
      type: 'information' },
    { date: 2016-08-17T03:44:42.123Z,
      duration: 1037,
      message: 'Job timed out (run time > 1 sec)',
      queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
      retryCount: 3,
      status: 'terminated',
      type: 'error' } ],
  data: 'The quick brown fox jumped over the lazy dog',
  priority: 'normal',
  progress: 0,
  queueId: 'WebDev:rjqJobQueueTests:rjqJobQueueTestJobs:7615:baad3b28-80c9-48ba-a800-73a2ae3a89a2',
  retryCount: 3,
  retryDelay: 2,
  retryMax: 3,
  status: 'terminated',
  timeout: 1 }

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally