You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We run our messenger consumer in a kubernetes cluster. For the pod I want to setup a liveness probe. So kubernetes will do some sort of check inside the pod to see if it is still running.
An easy way to do this is to write a file somewhere and then kubernetes checks if this file exists. Removes it, sleeps a bit and then checks again if the file is created.
For this I need to do be able to have a place that can write a file, even when no messages arrive. The Worker class is a suitable place because inside the run function the $onHandledCallback is constantly being called with a short sleep.
The problem is that you cannot add your own Worker or $onHandledCallback currently in the ConsumeMessagesCommand.
I would like to propose that you can add a custom $onHandledCallback or a custom set of Workers to the constructor of the ConsumeMessagesCommand.
The text was updated successfully, but these errors were encountered:
fabpot
closed this as <
75CB
a class="Link--secondary Link--inTextBlock" href="/symfony/symfony/issues?q=is%3Aissue+is%3Aclosed+archived%3Afalse+reason%3Acompleted">completed
Nov 4, 2019
This PR was merged into the 4.4 branch.
Discussion
----------
[Messenger] use events consistently in worker
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#32560, #32614, #33843
| License | MIT
| Doc PR |
The worker had the three ways to handle events
1. $onHandledCallback in `run(array $options = [], callable $onHandledCallback = null)`
2. events dispatched using the event dispatcher
3. hardcoded things inside the worker
This PR refactores the messenger worker to only use event dispatching. So instead of a hardcoded `$onHandledCallback` and worker decorators, we use event listeners and we don't need a `WorkerInterface` at all. The behavior of all the options like `--memory-limit` etc remains the same.
I introduced two new events
- `WorkerStartedEvent`
- `WorkerRunningEvent`
Together with the existing `WorkerStoppedEvent` it's very symmetrical and solves the referenced issues.
Commits
-------
201f159 [Messenger] use events consistently in worker
We run our messenger consumer in a kubernetes cluster. For the pod I want to setup a liveness probe. So kubernetes will do some sort of check inside the pod to see if it is still running.
An easy way to do this is to write a file somewhere and then kubernetes checks if this file exists. Removes it, sleeps a bit and then checks again if the file is created.
For this I need to do be able to have a place that can write a file, even when no messages arrive. The
Worker
class is a suitable place because inside therun
function the$onHandledCallback
is constantly being called with a short sleep.The problem is that you cannot add your own Worker or
$onHandledCallback
currently in theConsumeMessagesCommand
.I would like to propose that you can add a custom
$onHandledCallback
or a custom set of Workers to the constructor of theConsumeMessagesCommand
.The text was updated successfully, but these errors were encountered: