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).

<?php
namespace Tasks;

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

class titlesTask extends Task
{

    public function convertAction(){
        $queue = new Beanstalk( [ 'host' => '127.0.0.1', 'port' => '80', "persistent" => true, ] );
        $queue->choose('processTitle');
        $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' => '127.0.0.1', 'port' => '80', "persistent" => true,] );
        $queue->watch('processTitle');
        while ($queue->statsTube('processTitle')["current-jobs-ready"] > 0 && ($job = $queue->reserve())) {
             $message = $job->getBody();
            var_dump($message);

            $job->delete();
        }

        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)



76.8k

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

https://github.com/php-enqueue/enqueue-dev

its a big topic, i personally spend a lot of time making it working floweslly