Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Messenger] Add WorkerStoppedEvent #31282

Merged
merged 1 commit into from Apr 28, 2019

Conversation

Projects
None yet
6 participants
@chalasr
Copy link
Member

commented Apr 26, 2019

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.

@chalasr chalasr added the Messenger label Apr 26, 2019

@chalasr chalasr requested a review from sroze as a code owner Apr 26, 2019

@chalasr chalasr added this to the next milestone Apr 26, 2019

@chalasr chalasr force-pushed the chalasr:messenger-worker-stop branch from bebd354 to 8b81fad Apr 27, 2019

@chalasr chalasr force-pushed the chalasr:messenger-worker-stop branch from 8b81fad to 4733c22 Apr 27, 2019

@chalasr chalasr force-pushed the chalasr:messenger-worker-stop branch from 4733c22 to 0e7898b Apr 27, 2019

@sroze

sroze approved these changes Apr 28, 2019

Copy link
Member

left a comment

Makes sense 👍

@sroze

This comment has been minimized.

Copy link
Member

commented Apr 28, 2019

Thank you @chalasr.

@sroze sroze merged commit 0e7898b into symfony:master Apr 28, 2019

2 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
fabbot.io Your code looks good.
Details

sroze added a commit that referenced this pull request Apr 28, 2019

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
-------

0e7898b [Messenger] Add WorkerStoppedEvent

@chalasr chalasr deleted the chalasr:messenger-worker-stop branch Apr 28, 2019

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019

@weaverryan weaverryan referenced this pull request May 7, 2019

Open

[Messenger][4.3] Tracker for changes #11236

1 of 25 tasks complete

@fabpot fabpot referenced this pull request May 9, 2019

Merged

Release v4.3.0-BETA1 #31435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.