Beanstalk\Job Class Ref

class Beanstalk\Job
Description:A Beanstalkd job
Author:Joshua Dechant <jdechant@shapeup.com>

Class Methods

Beanstalk\Job::__construct($conn, $id, $message)
Description:

Constructor

Parameters:
  • $conn (BeanstalkConnection) – Connection for the job
  • $id (integer) – Job id
  • $message (string) – Job body. If the body is JSON, it will be converted to an object
Beanstalk\Job::bury([$priority = 2048])
Description:

Bury the job

Parameters:
  • $priority (integer) – A new priority to assign to the job

The bury command puts a job into the “buried” state. Buried jobs are put into a FIFO linked list and will not be touched by the server again until a client kicks them with the “kick” command.

Beanstalk\Job::delete()
Description:Delete the job
Returns:boolean
Throws:BeanstalkException

The delete command removes a job from the server entirely. It is normally used by the client when the job has successfully run to completion.

Beanstalk\Job::getConnection()
Description:Get the beanstalkd connection for the job
Returns:BeanstalkConnection
Beanstalk\Job::getId()
Description:Get the job id
Returns:integer
Beanstalk\Job::getMessage()
Description:Get the job body/message
Returns:mixed String of body for simple message; stdClass for JSON messages
Beanstalk\Job::release([$delay = 10, $priority = 5])
Description:

Release the job

Parameters:
  • $delay (integer) – Number of seconds to wait before putting the job in the ready queue.
  • $priority (integer) – A new priority to assign to the job
Returns:

boolean

Throws:

BeanstalkException

The release command puts a reserved job back into the ready queue (and marks its state as “ready”) to be run by any client. It is normally used when the job fails because of a transitory error.

Beanstalk\Job::stats()
Description:Get stats on the job
Returns:BeanstalkStats
Throws:BeanstalkException When the job does not exist

The stats-job command gives statistical information about the specified job if it exists.

Beanstalk\Job::touch()
Description:Touch the job
Returns:boolean
Throws:BeanstalkException

The “touch” command allows a worker to request more time to work on a job. This is useful for jobs that potentially take a long time, but you still want the benefits of a TTR pulling a job away from an unresponsive worker. A worker may periodically tell the server that it’s still alive and processing a job (e.g. it may do this on DEADLINE_SOON).