File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 13
13
use JsonException ;
14
14
use PhpAmqpLib \Channel \AMQPChannel ;
15
15
use PhpAmqpLib \Connection \AbstractConnection ;
16
+ use PhpAmqpLib \Exception \AMQPChannelClosedException ;
17
+ use PhpAmqpLib \Exception \AMQPConnectionClosedException ;
16
18
use PhpAmqpLib \Exception \AMQPProtocolChannelException ;
19
+ use PhpAmqpLib \Exception \AMQPRuntimeException ;
17
20
use PhpAmqpLib \Exchange \AMQPExchangeType ;
18
21
use PhpAmqpLib \Message \AMQPMessage ;
19
22
use PhpAmqpLib \Wire \AMQPTable ;
@@ -254,6 +257,16 @@ public function pop($queue = null)
254
257
}
255
258
256
259
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
+ );
257
270
}
258
271
259
272
return null ;
You can’t perform that action at this time.
0 commit comments