kafka-php
kafka-php copied to clipboard
How to stop consumer?
How I can stop consumer now? I getting a looping script which working all the time, but what if I need to stop that? Of course, I can write some script that will find PHP process and kill that, but it will an ugly way.
+1
Found that internally the consumer is using Amp\Reactor which is generated as a singleton via Amp\reactor() method. This provides a couple of options:
- Schedule a callback to
->stop()the reactor viareactor()->once(...),reactor()->repeat(...), orreactor()->immediately(...) - In the consumer callback, call
reactor()->stop()- Main downside is that you have to wait for a message to be consumed before this code is called