This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Messenger
Samuel ROZE 96a7907979 feature #31282 [Messenger] Add WorkerStoppedEvent (chalasr)
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
-------

0e7898b622 [Messenger] Add WorkerStoppedEvent
2019-04-28 14:59:42 +01:00
..
Command [FrameworkBundle] Drop unused private method 2019-04-25 15:38:48 +02:00
DataCollector fixed CS 2019-01-16 21:35:37 +01:00
DependencyInjection Merge branch '4.2' 2019-04-27 14:01:28 +02:00
Event [Messenger] Add WorkerStoppedEvent 2019-04-27 20:22:09 +02:00
Exception Rename exception, add change log and a few other things 2019-04-06 14:41:06 +02:00
Handler fixed CS 2019-01-16 21:35:37 +01:00
Middleware [Messenger] ease testing and allow forking the middleware stack 2019-04-23 13:19:34 +02:00
Retry Adding global retry support, events & more to messenger transport 2019-03-23 09:39:27 -04:00
Stamp Ensure message is handled only once per handler 2019-04-06 14:40:48 +02:00
Test/Middleware [Messenger] ease testing and allow forking the middleware stack 2019-04-23 13:19:34 +02:00
Tests feature #31282 [Messenger] Add WorkerStoppedEvent (chalasr) 2019-04-28 14:59:42 +01:00
Transport feature #30917 [Messenger] Add a redis stream transport (soyuka, alexander-schranz) 2019-04-27 17:54:07 +01:00
Worker [Messenger] fix review 2019-03-31 19:00:04 +02:00
CHANGELOG.md [Messenger] Add WorkerStoppedEvent 2019-04-27 20:22:09 +02:00
composer.json [Messenger] test DoctrineTransport on travis and appveyor 2019-04-05 16:21:26 +02:00
Envelope.php Allow stamps to be passed directly to MessageBusInterface::dispatch() 2019-03-31 12:05:21 -04:00
HandleTrait.php [Messenger] Add a trait for synchronous query & command buses 2018-11-20 19:19:09 +01:00
LICENSE Merge branch '3.4' into 4.1 2019-01-03 10:05:57 +01:00
MessageBus.php Allow stamps to be passed directly to MessageBusInterface::dispatch() 2019-03-31 12:05:21 -04:00
MessageBusInterface.php Allow stamps to be passed directly to MessageBusInterface::dispatch() 2019-03-31 12:05:21 -04:00
phpunit.xml.dist Merge branch '3.4' into 4.1 2018-11-11 20:51:29 +01:00
README.md Fix README about BC promise 2019-03-12 18:23:22 +01:00
RoutableMessageBus.php Allow stamps to be passed directly to MessageBusInterface::dispatch() 2019-03-31 12:05:21 -04:00
TraceableMessageBus.php Allow stamps to be passed directly to MessageBusInterface::dispatch() 2019-03-31 12:05:21 -04:00
Worker.php [Messenger] Add WorkerStoppedEvent 2019-04-27 20:22:09 +02:00
WorkerInterface.php fixed typos 2019-03-30 08:02:29 +01:00

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.

Resources