...
The JSMA job provides the following methods:
job jobs.execute(title, profile, [data], [portal])
...
int job.id
Returns the job's database ID
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
var id = job.id # => 1
... |
string job.status
Returns the job's status field
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
var status = job.status; # => 'done'
... |
object job.data
Returns the job's data object
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
var data = job.data; # => { some: 'arguments', ... }
... |
array job.log
Returns the job's log array in chronological order.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... job.execute(title, profile, [data], [portal])var log = job.log; # => [{"type"=>"success", "message"=>"{\"status\": \"OK\"}", "time"=>"2018-09-21 13:48:17 +0200"}, ...] ... |
Parameter title:string (required)
The title for the particular job.
Parameter profile:string (required)
...
void job.retry()
Resets the job status and tries. The job will be scheduled for retry. The log persists.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
job.retry()
... |
void job.cancel()
Cancels the job if it is scheduled to run.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
job.cancel()
... |
void job.update(data)
Updates the job's data object.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... job.update({ foo: 'bar' }); ... |
Parameter data:object (
...
required)
An arbitrary JS Object. This will be made available to the handler as the first argument. (args[0]
)
Parameter portal:portal (optional)
The portal in which scope the job is run. Either a JSMA portal, or the uuid of a portal. Defaults to the portal of the request which called this method.
job jobs.findById(id)
Retrieve a job by IDobject.
void job.setError(message)
Sets the state of the job to 'error'. If there are tries left for this job it will be scheduled for retrying according to the 'wait' setting of the job profile.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
...
job.setError('some error occurred');
... |
Parameter message:string (required)
The error message that will be logged.
void job.setFatal(message)
Sets the state of the job to 'fatal'. No further retries will be made.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... var job.setFatal('some = jobs.findById(1fatal error'); ... |
Parameter
...
message:
...
string (required)
The ID to look uperror message that will be logged.
void job
...
.
...
setExecutionState(state)
Sets the executionState
value of the job to 'fatal'. No further retries will be made.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... var job = jobs.current.setExecutionState(1); ... |
Parameter state:int (required)
The integer to be set as executionState
.