All Projects → anorgan → Qutee

anorgan / Qutee

Licence: lgpl-2.1
PHP Background Jobs (Tasks) Manager

Projects that are alternatives of or similar to Qutee

celery.node
Celery task queue client/worker for nodejs
Stars: ✭ 164 (+160.32%)
Mutual labels:  queue, workers, background-jobs, task-runner, job-queue
Rq
Simple job queues for Python
Stars: ✭ 8,065 (+12701.59%)
Mutual labels:  workers, background-jobs, job-queue, redis
Honeydew
Job Queue for Elixir. Clustered or Local. Straight BEAM. Optional Ecto. 💪🍈
Stars: ✭ 670 (+963.49%)
Mutual labels:  workers, job-queue, queue
Resque
Resque is a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.
Stars: ✭ 9,031 (+14234.92%)
Mutual labels:  queue, background-jobs, job-queue
Redis Smq
A simple high-performance Redis message queue for Node.js.
Stars: ✭ 230 (+265.08%)
Mutual labels:  job-queue, redis, queue
Node Celery
Celery client for Node.js
Stars: ✭ 648 (+928.57%)
Mutual labels:  background-jobs, redis, queue
Django Rq
A simple app that provides django integration for RQ (Redis Queue)
Stars: ✭ 1,361 (+2060.32%)
Mutual labels:  background-jobs, job-queue, redis
Exq
Job processing library for Elixir - compatible with Resque / Sidekiq
Stars: ✭ 1,218 (+1833.33%)
Mutual labels:  job-queue, redis, queue
Toro
Multithreaded message processing on Postgres
Stars: ✭ 39 (-38.1%)
Mutual labels:  workers, background-jobs, queue
Simpleue
PHP queue worker and consumer - Ready for AWS SQS, Redis, Beanstalkd and others.
Stars: ✭ 124 (+96.83%)
Mutual labels:  workers, redis, queue
Sidekiq Job Php
Push and schedule jobs to Sidekiq from PHP
Stars: ✭ 34 (-46.03%)
Mutual labels:  workers, redis, queue
Kiq
📮 Robust job queue powered by GenStage and Redis
Stars: ✭ 49 (-22.22%)
Mutual labels:  workers, background-jobs, redis
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+9139.68%)
Mutual labels:  redis, queue
Que
Simple Job Processing in Elixir with Mnesia ⚡️
Stars: ✭ 612 (+871.43%)
Mutual labels:  background-jobs, job-queue
Taskq
Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends
Stars: ✭ 555 (+780.95%)
Mutual labels:  redis, queue
Verk
A job processing system that just verks! 🧛‍
Stars: ✭ 666 (+957.14%)
Mutual labels:  workers, redis
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+1003.17%)
Mutual labels:  redis, queue
Fennel
A task queue library for Python and Redis
Stars: ✭ 24 (-61.9%)
Mutual labels:  redis, queue
Asynq
Asynq: simple, reliable, and efficient distributed task queue in Go
Stars: ✭ 934 (+1382.54%)
Mutual labels:  background-jobs, redis
Flower
Real-time monitor and web admin for Celery distributed task queue
Stars: ✭ 5,036 (+7893.65%)
Mutual labels:  workers, redis

QuTee

Build Status Coverage Status

Simple queue manager and task processor for PHP using Beanstalkd, Redis or MySQL as backend. Event interface is provided for your logging or statsd-ing needs.

Example

<?php
/*
 * Bootstrap / DIC
 */
$beanstalkdParams    = array(
    'host'  => '127.0.0.1',
    'port'  => 11300
);
$queuePersistor = new Qutee\Persistor\Beanstalk();
$queuePersistor->setOptions($beanstalkdParams);

// or...

$redisParams    = array(
    'host'  => '127.0.0.1',
    'port'  => 6379
);
$queuePersistor = new Qutee\Persistor\Redis();
$queuePersistor->setOptions($redisParams);

// or...

$pdoParams    = array(
    'dsn'       => 'mysql:host=127.0.0.1;dbname=test;charset=utf8',
    'username'  => 'root',
    'password'  => '',
    'table_name'=> 'queue'
);
$queuePersistor = new Qutee\Persistor\Pdo();
$queuePersistor->setOptions($pdoParams);

$queue          = new Queue();
$queue->setPersistor($queuePersistor);

/*
 * App
 */

// Create Task
$task = new Task;
$task
    ->setName('Acme/DeleteFolder')
    ->setData(array(
        'path'      => '/usr',
    ))
    ->setPriority(Task::PRIORITY_HIGH);

// Queue it
$queue->addTask($task);

// Or do this in one go
Task::create('Acme/DeleteFolder', array('path' => '/usr'), Task::PRIORITY_HIGH);
<?php
// Worker - process all queues
$worker = new Worker;
while (true) {
    try {
        $worker->run();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}

// Or, with more configuration
$worker = new Worker;
$worker
    ->setInterval(30)                           // Run every 30 seconds
    ->setPriority(Task::PRIORITY_HIGH)          // Will only do tasks of this priority
    ;

while (true) {
    try {
        if (null !== ($task = $worker->run())) {
            echo 'Ran task: '. $task->getName() . PHP_EOL;
        }
    } catch (Exception $e) {
        echo 'Error: '. $e->getMessage() . PHP_EOL;
    }
}

Logging example

// Initialize queue with persistor
$queue          = new Qutee\Queue();

// Setup the dispatcher, and register your subscriber
$dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher;
$dispatcher->addSubscriber(new QuteeEventSubscriber());
$queue->setEventDispatcher($dispatcher);

// The subscriber:
class QuteeEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            \Qutee\Queue::EVENT_ADD_TASK => array(
                'addTask',
                0
            ),
            \Qutee\Worker::EVENT_START_PROCESSING_TASK => array(
                'processTask',
                0
            ),
            \Qutee\Worker::EVENT_END_PROCESSING_TASK => array(
                'processTaskEnd',
                0
            ),
        );
    }
    
    public function addTask(Qutee\Event $event)
    {
        $this->log('Added task: '. $event->getTask()->getName());
    }
    
    public function processTask(Qutee\Event $event)
    {
        $this->log('Processing task '. $event->getTask()->getName() .' started');
    }
    
    public function processTaskEnd(Qutee\Event $event)
    {
        $this->log('Processing task '. $event->getTask()->getName() .' finished, lasted '. ($event->getArgument('elapsedTime') / 1000) .' seconds');
    }
    
    protected function log($message)
    {
        file_put_contents(__DIR__ .'/events.log', $message . PHP_EOL, FILE_APPEND);
    }

}

Notes

  • Use supervisord or similar for process monitoring / babysitting

TODO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].