Skip to content

Job Format

Steven Harman edited this page Jul 29, 2013 · 15 revisions

Sidekiq serializes jobs to Redis in JSON format. Each Job is a simple Hash of data.

Job

At bare minimum, a job requires three fields:

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

args is splatted into an instance of 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.123
}

Retries

Sidekiq's retry feature adds several elements to the job payload, necessary for documenting the error in the UI:

{
  "retry_count": 2, // number of times we've retried so far
  "error_message": "wrong number of arguments (2 for 3)", // the exception message
  "error_class": "ArgumentError", // the exception class
  "error_backtrace": ["line 0", "line 1", ...], // some or all of the exception's backtrace, optional, array of strings
  "failed_at": "2013-07-29 03:26:41 UTC", // the first time the job failed
  "retried_at": "2013-07-29 03:26:56 UTC" // the last time the job failed
}

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