Pause all queue workers?
(and scheduled jobs)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
For some reasons, I need to add a button to let the user reset the entire database.
But it's a real time application and messages come from RabbitMQ and are handled by the application and needs to access to the DB.
RabbitMQ and the other services have to continue running while resetting the database.
How can I do to avoid the application to throw errors during resetting the DB ?
I have these ideas :
set a RESETTING_DATABASE flag in the session
handle the messages from RabbitMQ only if the flag is true
set the flag to false, reset the database, set the flag to true
Do you see any other ways to do that ?
Thanks for your help.
V
Not sure what you mean by resetting the whole database, are we talking a full php artisan migrate:fresh --seed?
Like @snapey says, make sure to stop all the jobs reading from the queue before changing anything in the database, a simple maintenance global that is checked by all the jobs that reads the queues.
if (! $maintenance) {
fetchContractFromQueue($contract);
}
Please or to participate in this conversation.