class BatchJob extends BackgroundJob

Class BatchJob (FOR INTERNAL TESTS ONLY) Should be used to execute many jobs at once

Use batch job to track total progress, e.g. if 10 of 100 jobs have completed the batch job could return 10% and could finish when the last job has been completed

Properties

protected string $queue from  BackgroundJob
protected int $maxRetries from  BackgroundJob
protected int $retryDelay from  BackgroundJob
protected callable $statusUpdateCallback

Callback tor status updates

from  BackgroundJob
protected string|null $uniquenessKey from  BackgroundJob
protected string|null $referenceId from  BackgroundJob
protected $idToken

Token ID - available during Execution

from  BackgroundJob
protected int $reScheduleDelay

If not 0 the job will be re-scheduled in the passed amount of seconds

from  BackgroundJob
protected string $reScheduledJobId from  BackgroundJob
protected $jobs
protected $jobTokens

Methods

addJob(BackgroundJob $job)

Adds a BackgroundJob to this batch job

void
callEventHandler(string $eventName)

No description

clearJobs()

No description

continueWith(BackgroundJob $job, int $delayInSeconds = 0)

No description

bool
execute()

Schedule all jobs in this batch

string|null
getIdToken()

No description

JobQueueController|null
getJobQueueModule()

Helper to get the JobQueue module

int
getMaxRetries()

No description

int
getReScheduleDelay()

Returns the number of seconds if the tasks should be rescheduled or false if not

string|null
getReferenceId()

Define a reference ID which can later be used to lookup this job

int
getRetryDelay()

No description

string|null
getUniquenessKey()

Can be implemented on the Job to avoid running the same task multiple times at once If the task already exists in the queue and is waiting or in process the next tasks won't be scheduled

array
jsonSerialize()

No description

void
onAbort()

Note: This event always is being triggered by the job runner

void
onCancel()

Note: This event always is being triggered by the job runner

void
onFinish()

Note: This event always is being triggered by the job runner

void
onRetry()

Note: This event always is being triggered by the job runner

void
onScheduled()

Note: This event may happen in the Frontend call

reSchedule(int $delayInSeconds = 0)

Reschedule the currently running task (can only be used in execute() function)

schedule(int $delayInSeconds = 0)

No description

string
serialize()

Encodes all relevant settings for this job into a json string

setIdToken(string $idToken)

No description

setReScheduledJobId(string $jobId)

No description

setReferenceId(string $referenceId)

Define a reference ID which can later be used to lookup this job

setStatusUpdateCallback(callable $callback)

Sets the callback which should be called if the job needs to update its status As the BackgroundJob has no context of the job itself this function is only available from within the execution context (daemon)

setUniquenessKey(string $uniqueKey)

Can be implemented on the Job to avoid running the same task multiple times at once If the task already exists in the queue and is waiting or in process the next tasks won't be scheduled

updateStatusMessage(string $messageToken)

Updates the status message for this job which is being shown in user output (can only be used in execute() function)

updateStatusProgress(int $progress)

Updates the status progress for this job (can only be used in execute() function)

bool
validate()

If the return is false, the job will not be executed.

Details

at line 66
addJob(BackgroundJob $job)

Adds a BackgroundJob to this batch job

Parameters

BackgroundJob $job

Exceptions

JsonException

in BackgroundJob at line 305
void callEventHandler(string $eventName)

No description

Parameters

string $eventName

Return Value

void

at line 73
clearJobs()

No description

in BackgroundJob at line 265
BackgroundJob continueWith(BackgroundJob $job, int $delayInSeconds = 0)

No description

Parameters

BackgroundJob $job
int $delayInSeconds

Return Value

BackgroundJob

Exceptions

JsonException

at line 28
bool execute()

Schedule all jobs in this batch

Return Value

bool

Returns true if the execute was successful or false in case of errors

in BackgroundJob at line 148
string|null getIdToken()

No description

Return Value

string|null

in BackgroundJob at line 293
protected JobQueueController|null getJobQueueModule()

Helper to get the JobQueue module

Return Value

JobQueueController|null

in BackgroundJob at line 75
int getMaxRetries()

No description

Return Value

int

in BackgroundJob at line 134
int getReScheduleDelay()

Returns the number of seconds if the tasks should be rescheduled or false if not

Return Value

int

in BackgroundJob at line 112
string|null getReferenceId()

Define a reference ID which can later be used to lookup this job

Return Value

string|null

in BackgroundJob at line 79
int getRetryDelay()

No description

Return Value

int

in BackgroundJob at line 89
string|null getUniquenessKey()

Can be implemented on the Job to avoid running the same task multiple times at once If the task already exists in the queue and is waiting or in process the next tasks won't be scheduled

Return Value

string|null

in BackgroundJob at line 314
array jsonSerialize()

No description

Return Value

array

in BackgroundJob at line 185
void onAbort()

Note: This event always is being triggered by the job runner

Return Value

void

in BackgroundJob at line 192
void onCancel()

Note: This event always is being triggered by the job runner

Return Value

void

in BackgroundJob at line 171
void onFinish()

Note: This event always is being triggered by the job runner

Return Value

void

in BackgroundJob at line 178
void onRetry()

Note: This event always is being triggered by the job runner

Return Value

void

in BackgroundJob at line 164
void onScheduled()

Note: This event may happen in the Frontend call

Return Value

void

in BackgroundJob at line 203
protected reSchedule(int $delayInSeconds = 0)

Reschedule the currently running task (can only be used in execute() function)

Parameters

int $delayInSeconds

in BackgroundJob at line 246
BackgroundJob schedule(int $delayInSeconds = 0)

No description

Parameters

int $delayInSeconds

Return Value

BackgroundJob

Returns a Job Hash Id to access this job later on or FALSE if job could not be created

Exceptions

JsonException

in BackgroundJob at line 284
string serialize()

Encodes all relevant settings for this job into a json string

Return Value

string

Exceptions

JsonException

in BackgroundJob at line 141
setIdToken(string $idToken)

No description

Parameters

string $idToken

in BackgroundJob at line 155
setReScheduledJobId(string $jobId)

No description

Parameters

string $jobId

in BackgroundJob at line 123
BackgroundJob setReferenceId(string $referenceId)

Define a reference ID which can later be used to lookup this job

Parameters

string $referenceId

Return Value

BackgroundJob

in BackgroundJob at line 233
setStatusUpdateCallback(callable $callback)

Sets the callback which should be called if the job needs to update its status As the BackgroundJob has no context of the job itself this function is only available from within the execution context (daemon)

Parameters

callable $callback

in BackgroundJob at line 101
BackgroundJob setUniquenessKey(string $uniqueKey)

Can be implemented on the Job to avoid running the same task multiple times at once If the task already exists in the queue and is waiting or in process the next tasks won't be scheduled

Parameters

string $uniqueKey

Return Value

BackgroundJob

in BackgroundJob at line 212
protected updateStatusMessage(string $messageToken)

Updates the status message for this job which is being shown in user output (can only be used in execute() function)

Parameters

string $messageToken

in BackgroundJob at line 222
protected updateStatusProgress(int $progress)

Updates the status progress for this job (can only be used in execute() function)

Parameters

int $progress

in BackgroundJob at line 69
bool validate()

If the return is false, the job will not be executed.

Return Value

bool