Skip to content

Allow laravel to end workers with lost connection #457

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

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

violarium
Copy link
Contributor

Exception thrown by ::pop is checked by Illuminate\Database\DetectsLostConnections::causedByLostConnection
It should throw exception with special message in order to end queue on error correctly.
Otherwise it continues to work with broken connection.

#421
#436

…stConnections::causedByLostConnection

It should throw exception with special message in order to end queue on error correctly.
Otherwise, it continues to work with broken connection.
@roboticsexpert
Copy link

it fixes the issue !

@Shipu
Copy link

Shipu commented Jan 8, 2022

It's solve the issue but still sometime lost connection.

@violarium
Copy link
Contributor Author

violarium commented Jan 12, 2022

It's solve the issue but still sometime lost connection.

This fix is not to prevent lost connection - it can happen because of network or something else.

When connection is lost Laravel worker should restart queue. But with rabbitmq it doesn't do it. It just continue to work with lost connection, spamming errors.

This fix makes Laravel work with queue properly and restart it.

@violarium violarium marked this pull request as ready for review January 12, 2022 06:22
@amiranbarigreenweb
Copy link

This is what im looking for ...

@ar2r
Copy link

ar2r commented Feb 17, 2022

Did this code helps someone? Now i inject this code in my project and after 2-3 days i will tell my result.

@violarium
Copy link
Contributor Author

Did this code helps someone? Now i inject this code in my project and after 2-3 days i will tell my result.

I'am an author of this. You better not inject, but use this: #436 (comment)

For my projects it works fine for 2 months. It, ofcource, doesn't prevent lost connection to rabbit. But worker get restarted by laravel as it was intended.

@kovalovme
Copy link

@vyuldashev please review

@xanloboi
Copy link

xanloboi commented Apr 6, 2022

@vyuldashev , please review

@henrylynch
Copy link

Morning! Do anyone know when this will be reviewed?

@artemprotech
Copy link

@vyuldashev please review. We need it.

@vyuldashev vyuldashev merged commit 7c7ac39 into vyuldashev:master Apr 6, 2022
@vyuldashev
Copy link
Owner

Sorry, I am a little bit busy at the moment. Thanks for the contribution. Released under v12.0.1

@kovalovme
Copy link

Thanks a lot!

@kovalovme
Copy link

Any chance you can support 11.x version?
Laravel 9 migration is pretty complex

Thank you again!

Copy link

@BinZhiZhu BinZhiZhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@@ -254,6 +257,16 @@ public function pop($queue = null)
}

throw $exception;
} catch (AMQPChannelClosedException|AMQPConnectionClosedException $exception) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

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

Successfully merging this pull request may close these issues.