Skip to content

Job Format

Mike Perham edited this page Jul 29, 2013 · 15 revisions

Sidekiq serializes jobs to Redis in JSON format.

Job

At bare minimum, a job requires three fields:

{
  "class": "SomeWorker",
  "jid": <12-byte random number as 24 char hex string>,
  "args": [1, "arg", true],
}

args is splatted onto the worker class's perform method.

Worker Options

When a job is serialized, the options for the Worker are serialized as part of the job payload:

{
  "queue": "default",
  "retry": true,
}

Scheduled Jobs

The at element stores when a job was scheduled to execute, in Unix epoch format:

{
  "at": 1234567890
}

Retries

Sidekiq's retry feature adds several elements to the job payload:

  • retry_count - number of times we've retried so far
  • error_message - the exception message
  • error_class - the exception class
  • error_backtrace - some or all of the exception's backtrace, optional, array of strings
  • failed_at - the first time the job failed
  • retried_at - the last time the job failed

The two times are stored as Strings in Ruby's default format Time.now.utc.to_s.