Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,17 @@ public function getCorrelationId()
/**
* @param string $action
* @param Exception $e
* @throws Exception
*/
protected function reportConnectionError($action, Exception $e)
{
Log::error('AMQP error while attempting '.$action.': '.$e->getMessage());

// If it's set to false, throw an error rather than waiting
if ($this->sleepOnError === false) {
throw new \RuntimeException('Error writing data to the connection with RabbitMQ');
}

// Sleep so that we don't flood the log file
sleep($this->sleepOnError);
}
Expand Down
4 changes: 3 additions & 1 deletion src/config/rabbitmq.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
],

'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5), // the number of seconds to sleep if there's an error communicating with rabbitmq
// the number of seconds to sleep if there's an error communicating with rabbitmq
// if set to false, it'll throw an exception rather than doing the sleep for X seconds
'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5),

];