ZuloOne
English
Sign in
Menu

Job — background job

Updated

What it is#

Code on a schedule (cron), without a user launch from a UI form: periodic selections/integrations (fetch submission statuses, apply a regime change, pull a bank statement). It is separate from Script as a kind, although it is also a JSON+CS pair, because it carries a schedule and queue parameters that an event handler does not have.

JSON envelope#

<Name>.json (envelope) + <Name>Task.script.json+.cs (body) in one folder:

{
  "kind": "Job",
  "object": {
    "description": "Переводит юрлица на общую систему по дате из журнала UaRegimeChange.",
    "scriptMetaId": "<GUID Script>",
    "cronExpression": "0 3 * * *",
    "isActive": true,
    "executeSingle": true,
    "queueTtlMinutes": 60,
    "metaId": "<GUID Job>", "name": "ApplyUaRegimeChanges", "modelId": "<GUID Model>"
  }
}

executeSingle: true means the platform does not enqueue a second run while the current one has not finished (protection against overlapping long runs); queueTtlMinutes is how long to wait for a worker before considering the run missed.

When the schedule does not fire#

  • While integration tests run. A test case rolls back what it writes; a job commits on its own connection. The scheduler skips its tick while any test run is in flight on the stand. A job due in that minute waits for its next matching minute.
  • When the stand turns the scheduler off. ZuloOne:Jobs:Scheduler = false (environment variable ZuloOne__Jobs__Scheduler=false) stops every schedule for the life of the process. The workspace CI stand sets it. The default is true. Run-now and Db.RunJobAsync in a test still run a job.

C# base#

The job body is a normal handler script (scriptType of the job class). The signature is in .generated/Frameworks/; inside it the same root services are available (GetService<T>()) as in any script.

Events / Chain of Command#

No chain — one job, one handler. By convention, several jobs with the same cron do not compete for the same business operation: each job owns its own process step.

Example#

ApplyUaRegimeChanges in LocalizationUkraine — runs daily at 03:00 and moves a legal entity to the general system by the date in the journal.

Was this page helpful?