We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Obtaining status of a task(Beanstalk)

Hello community! Please tell me. How can I get status of the task of its identifier?

I get ID:

$id = $queue->put(array('createJob' => mt_rand(1,5)));

And?



1.9k
Accepted
answer

Problem solved. Phalcon have special class for this task, but in documentation i not found this: https://github.com/phalcon/cphalcon/blob/2.1.x/phalcon/queue/beanstalk/job.zep



58.4k

Hey

You can see documents Beanstalk at https://docs.phalcon.io/en/latest/api/Phalcon_Queue_Beanstalk.html, Also you can use example my code to see ID

    $job = $this->queue->reserve();
    $message = $job->getBody();
edited Mar '16

One note for Beanstalk / Phalcon implementation.

If you're using reserve() method, it's better to call connect() on each iteration:

//Calling method connect() on a shared MessageBroker instance is the fastest approach
$this->messageBroker->connect();

W/o this, your loop gets slow (it seems that the class is trying to find previous connection).