File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1313use JsonException ;
1414use PhpAmqpLib \Channel \AMQPChannel ;
1515use PhpAmqpLib \Connection \AbstractConnection ;
16+ use PhpAmqpLib \Exception \AMQPChannelClosedException ;
17+ use PhpAmqpLib \Exception \AMQPConnectionClosedException ;
1618use PhpAmqpLib \Exception \AMQPProtocolChannelException ;
19+ use PhpAmqpLib \Exception \AMQPRuntimeException ;
1720use PhpAmqpLib \Exchange \AMQPExchangeType ;
1821use PhpAmqpLib \Message \AMQPMessage ;
1922use PhpAmqpLib \Wire \AMQPTable ;
@@ -254,6 +257,16 @@ public function pop($queue = null)
254257 }
255258
256259 throw $ exception ;
260+ } catch (AMQPChannelClosedException |AMQPConnectionClosedException $ exception ) {
261+ // Queue::pop used by worker to receive new job
262+ // Thrown exception is checked by Illuminate\Database\DetectsLostConnections::causedByLostConnection
263+ // Is has to contain one of the several phrases in exception message in order to restart worker
264+ // Otherwise worker continues to work with broken connection
265+ throw new AMQPRuntimeException (
266+ 'Lost connection: ' .$ exception ->getMessage (),
267+ $ exception ->getCode (),
268+ $ exception
269+ );
257270 }
258271
259272 return null ;
You can’t perform that action at this time.
0 commit comments