Skip to content

Visual-Craft/work-queue-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Work Queue Symfony bundle

Background jobs using Beanstalk (Symfony bundle)

Install

$ composer require visual-craft/work-queue-bundle

Configure

##config/packages/visual_craft_work_queue.yaml

visual_craft_work_queue:
    connections:
        default: ~
    queues:
        test_queue:
            connection: default
            worker: 'App\BackgroundJob\Worker\TestWorker'

Create Worker

<?php

declare(strict_types=1);

namespace App\BackgroundJob\Worker;

use VisualCraft\WorkQueue\Worker\JobMetadata;
use VisualCraft\WorkQueue\Worker\WorkerInterface;

class TestWorker implements WorkerInterface
{
    public function work($payload, JobMetadata $metadata): void
    {
        //..
    }
}

Add service

services:
    App\Command\TestCommand:
        arguments:
            - '@visual_craft_work_queue.manager.test_queue'

Add queue

//..
private QueueManager $queueManager;

public function __construct(QueueManager $queueManager)
{
    $this->queueManager = $queueManager;
}

//..
    $this->queueManager->add('mixed payload');
//..

License

This code is released under the MIT license. See the complete license in the file: LICENSE

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages