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)



80.4k
edited Sep '18

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



80.4k
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.



80.4k
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