Queue Class
Namespace
Constants
Methods
blockingPop
Blocking pop operation that waits for a job without polling. This is the recommended solution for real-time queue processing.Pipeline name(s) to listen to. Use
'*' or 'all' for the default pipeline.Seconds to wait for a job. Use
0 for infinite timeout.Job instance if a job is available, false otherwise
Usage Example
processPipelineBlocking
Processes a pipeline using blocking pop. This is the recommended method for workers.Pipeline name(s) to process.
Block timeout in seconds.
true on successful job execution, false otherwise
Usage Example
push
Adds a Job or an array of jobs to a pipeline tail in the queue system.One or more jobs to add. Can be a Job instance, job class name, or array of either.
Pipeline name to add jobs to.
true on success
Usage Example
pushJob
Pushes a single job to a pipeline. Prevents duplicate jobs of the same class.Pipeline name.
Job instance to push.
true if job was added, false if duplicate exists
pop
Executes and removes a Job from the pipeline’s head.Pipeline name to pop from.
Job instance or false if no jobs available
Usage Example
processPipeline
Processes and executes all jobs from a pipeline.This method uses polling and should be avoided for workers. Use
processPipelineBlocking() instead for better performance.Pipeline name(s) to process. Use
'*' or 'all' to process all pipelines.Usage Example
getJobStatus
Gets a list of job UUIDs and their timestamps.Pipeline name to query.
Job state to filter by:
'completed', 'failed', or 'locked'.uuid and timestamp properties
Usage Example
clearJobStatus
Deletes all job statuses from the cache based on a pipeline name and state.State to clear:
'completed', 'failed', 'locked', or '*' for all.Pipeline name to clear statuses from.
Usage Example
Job Class
Namespace
Properties
Methods
__construct
Constructor that adds a UUID to each job.doWork
Abstract method that runs the job work. Must be implemented by all job classes.true if job completed successfully, false otherwise
Creating Custom Jobs
To create a custom job, extend theJob class and implement the doWork() method:
Queue Job Flow
- Job Creation - Job is instantiated and assigned a UUID
- Push to Queue - Job is serialized and added to a pipeline
- Worker Picks Job - Worker retrieves job using blocking or regular pop
- Job Locking - Job is locked to prevent duplicate processing
- Execution -
doWork()method is called - State Update - Job marked as completed or failed
- Unlock - Job lock is removed
Best Practices
- Use
processPipelineBlocking()for worker processes instead ofprocessPipeline() - Implement proper error handling in
doWork()method - Return
truefor successful execution,falsefor failures - Failed jobs are automatically re-queued for retry
- Use specific pipeline names to organize different job types
- Monitor job statuses using
getJobStatus()for debugging