mcfedr / doctrine-delay-queue-driver-bundle
A bundle for running symfony background tasks with doctrine as the driver
Installs: 20 949
Dependents: 0
Suggesters: 1
Security: 0
Stars: 2
Watchers: 2
Forks: 4
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- mcfedr/queue-manager-bundle: ^5.6.1
- symfony/framework-bundle: ^3.0|^4.0
- symfony/proxy-manager-bridge: ^3.3|^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.1
- incenteev/composer-parameter-handler: ^2.1
- mcfedr/sqs-queue-driver-bundle: ^3.4.2
- phpunit/phpunit: ^4.0|^5.3
- symfony/browser-kit: ^3.0|^4.0
- symfony/monolog-bundle: ^3.0|^4.0
README
A driver for Queue Manager Bundle that uses Doctrine to store delayed jobs
This driver doesn't run jobs, it requires another driver to actually process jobs.
It currently only works with MySQL as a native query is required to find jobs in a concurrency safe way.
Usage
You should run the daemon for delay in addition to any other daemons you are using. This runner simply moves jobs from Doctrine into your other job queues. Because its not doing much work generally a single instance can cope with a high number of jobs.
./bin/console mcfedr:queue:{name}-runner
Where {name}
is what you used in the config. Add -v
or more to get detailed logs.
Install
Composer
composer require mcfedr/doctrine-delay-queue-driver-bundle
AppKernel
Include the bundle in your AppKernel
public function registerBundles()
{
$bundles = [
...
new Mcfedr\QueueManagerBundle\McfedrQueueManagerBundle(),
new Mcfedr\DoctrineDelayQueueDriverBundle\McfedrDoctrineDelayQueueDriverBundle(),
Config
With this bundle installed you can setup your queue manager config similar to this:
mcfedr_queue_manager:
managers:
delay:
driver: doctrine_delay
options:
entity_manager: default
default_manager: default
default_manager_options: []
This will create a QueueManager
service named "mcfedr_queue_manager.delay"
entity_manager
- Doctrine entity manager to usedefault_manager
- Default job processordefault_manager_options
- Default options to pass to job processorput
Options to QueueManager::put
time
- A\DateTime
object of when to schedule this jobdelay
- Number of seconds from now to schedule this jobmanager
- Use a different job processor for this jobmanager_options
- Options to pass to the processorsput
method
Note
If delay
or time
option is less then 30 seconds the job will be scheduled for immediate execution
Tables
After you have installed you will need to do a schema update so that the table of delayed tasks is created