$job = Job::initNew(
Uuid::uuid4()->toString(),
ExampleReverseGeocodeCommand::fromLonLat(0.5, 0.5),
new \DateTimeImmutable()
);
$jobManager = new JobManager();
$jobManager->enqueueJob($job);- Possible to add additional workers to pool (for some group of tasks too)
- One task can be executed only by one worker at the same time (see acknowledgment + basic_qos)
- Ability to group jobs to chains that will be run sequentially examples:
- Ability to revoke handling job (in long-running iterable handlers too)
- Ability to view errors of handling and react to them
- Ability to re-run jobs
- composer package
- VueJs UI
- re-run jobs due deployment stuffs (for example after compatibility-breaking modifications of some JobCommand)
- several implementations of JobCommandFactoryInterface
- more plain command (JobCommandInterface is overweight)
- Bus - symfony/messenger bus
- Job - stored in DB (ORM) entity
- JobCommand - DTO that represents Job and will be used for transferring over Bus
- JobManager - service that will be used for enqueue Jobs or chain of Jobs
https://davegebler.com/post/php/how-to-create-a-symfony-5-bundle
# config/packages/messenger.yaml
framework:
messenger:
buses:
messenger.bus.default:
middleware:
- @core-extensions.job_queue.job_middleware
## ????
job_queue:
jobs_table: "orm_jobs"Shell command to run consumer:
ExecStart=php bin/console messenger:consume async --time-limit=3600 --id=worker_1