Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

How to stop consumer? #283

Open
djklim87 opened this issue Oct 21, 2019 · 2 comments
Open

How to stop consumer? #283

djklim87 opened this issue Oct 21, 2019 · 2 comments

Comments

@djklim87
Copy link

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.

@tezhm
Copy link

tezhm commented Jan 22, 2020

+1

@tezhm
Copy link

tezhm commented Jan 22, 2020

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 via reactor()->once(...), reactor()->repeat(...), or reactor()->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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants