forked from fhteam/laravel-amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
retry-after option related to fhteam#21
increment required php version to real value
- Loading branch information
1 parent
89d5e7f
commit 20b4c96
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Forumhouse\LaravelAmqp\Traits; | ||
use Exception; | ||
use Illuminate\Support\Str; | ||
|
||
trait AMQPFailureDetector | ||
{ | ||
|
||
public function catchAMQPConnectionFailure(Exception $exception) | ||
{ | ||
if(\App::runningInConsole() && $this->causedByLostConnection($exception) && extension_loaded('posix')){ | ||
posix_kill(getmypid(), SIGTERM); | ||
} | ||
} | ||
|
||
protected function causedByLostConnection(Exception $e) | ||
{ | ||
$message = $e->getMessage(); | ||
|
||
return Str::contains($message, [ | ||
'server has gone away', | ||
'no connection to the server', | ||
'Lost connection', | ||
'is dead or not enabled', | ||
'Error while sending', | ||
'decryption failed or bad record mac', | ||
'server closed the connection unexpectedly', | ||
'SSL connection has been closed unexpectedly', | ||
'Error writing data to the connection', | ||
'Resource deadlock avoided', | ||
'Transaction() on null', | ||
'child connection forced to terminate due to client_idle_limit', | ||
]); | ||
} | ||
} |