96a7907979
This PR was merged into the 4.3-dev branch.
Discussion
----------
[Messenger] Add WorkerStoppedEvent
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
In 4.2, one was able to decorate a transport and hook into `TransportInterface::stop()` to perform some business tasks when the `messenger:consume` process gets killed.
In 4.3 the `stop()` logic has been moved to `Worker` which cannot be decorated when used via `messenger:consume`.
This PR adds a marker event dispatched when the worker is stopped to provide the same capability.
Briefly discussed with @weaverryan.
My use case:
I have a temporary CSV file locally which grows while consuming jobs.
This file is uploaded to AWS S3 and squashed once a while (every 5minutes). It is also uploaded when the `messenger:consume` process gets stopped (to store the remaining lines).
For the former (time-based upload), I can listen on `WorkflowMessageHandledEvent` to make the upload happens in case the 5 minutes delay is elapsed. This solves the latter.
Commits
-------
|
||
---|---|---|
.. | ||
Command | ||
DataCollector | ||
DependencyInjection | ||
Event | ||
Exception | ||
Handler | ||
Middleware | ||
Retry | ||
Stamp | ||
Test/Middleware | ||
Tests | ||
Transport | ||
Worker | ||
CHANGELOG.md | ||
composer.json | ||
Envelope.php | ||
HandleTrait.php | ||
LICENSE | ||
MessageBus.php | ||
MessageBusInterface.php | ||
phpunit.xml.dist | ||
README.md | ||
RoutableMessageBus.php | ||
TraceableMessageBus.php | ||
Worker.php | ||
WorkerInterface.php |
Messenger Component
The Messenger component helps application send and receive messages to/from other applications or via message queues.
This Component is experimental. Experimental features are not covered by Symfony's Backward Compatibility Promise.