I'm using "Yii2 Queue Extension" in my Yii2 Basic Application configured with Beanstalk. I am pushing jobs into the queue using the command:
Yii::$app->queue->push(new FilterData(['filter_data' => $data]));
FilterData is my job class, where i am processing some calculations in the background. Now i want to know about, is there any way where i can put my job into the Bury State? I don't want to delete my job if some conditions get failed, i want to store that so i can process it later on.
Below is the URL for the library that i am using in my Yii2 Application to implement Queue.
https://github.com/yiisoft/yii2-queue
I have tried it using getPheanstalk() (this method was protected, but i changed it to the public for an instance) function of beanstalk queue class, but was unable to do that.
public function execute($queue)
{
try {
if (empty($this->filter_data)) { // if data does not exists don't process the code
// here i want my job to move in bury state and i tried below code
$queue->getPheanstalk()->bury($this);
throw new \Exception('Error Filter Data cannot be empty');
}
$result = // Database query to fetch records and if exists then move further
if (empty($result)) { // If details not found
// here i want my job to move in bury state and i tried below code
$queue->getPheanstalk()->bury($this);
throw new \Exception('Filter Details were not found');
}
/*
* execute further code
*/
} catch (\Exception $e) {
print_r($e->getMessage());
}
}
I want to push my job into the buried state, so can anyone please tell me how i can achieve that?