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

Queue (Beanstalk)

Hi. I'm having trouble/difficulty learning about queue/beanstalk. I have a task that is called via cli (every x times) or via web (admin panel) and this task should only add a process to queue. Task: (convert .mkv to .mp4).

namespace Tasks;

use Phalcon\CLI\Task;
use Phalcon\Queue\Beanstalk;

class titlesTask extends Task

    public function convertAction(){
        $queue = new Beanstalk( [ 'host' => '', 'port' => '80', "persistent" => true, ] );
        $queue->put( [ 'processTitle' => ['/path/to/file.mkv', '/path/to/output.mp4'], ]);


    public function processTitle($inputFile, $outputFile){

        shell_exec("ffmpeg -i {$inputFile} -vcodec copy -acodec copy {$outputFile}");

        // this will add that file to DB;
        $this->console->handle(["task" => "title", "action" => "import", "params" => [$outputFile]]);


    public function listenAction(){

        $queue = new Beanstalk( [ 'host' => '', 'port' => '80', "persistent" => true,] );
        while ($queue->statsTube('processTitle')["current-jobs-ready"] > 0 && ($job = $queue->reserve())) {
             $message = $job->getBody();


        echo 'No Videos to Proccess';



I also want to have a terminal window opened to see how the process is going. (php cli titles listen)

edited Sep '18

sine predis died ( even tho its still working ), i think this is what people are using these days


its a big topic, i personally spend a lot of time making my apllication working with queue services

@Izo could you please share what tooling obstacles did you run into? I'd be happy to improve DX.

edited Sep '18

Hi Max,

I did not understand the question sorry. "DX" ?

//i am bit away from keyboard these days since i broke my arm, so i reponce i bit slowly

Developer experience. If you tell me what problems you faced I might find a way to improve it.

edited Sep '18

oh sorry, i ment I spend time on predis. Enqueue is on a whole new level , examples are great. I am currently using google pub/sub and its working great.

//i will edit my comment to make more sense. Feels like some comments has been deleted, cuz my original answer doesn't make much sense as an answer to this specific post