Skip to content

Commit 1c27893

Browse files
author
paramtamtam
committed
Fix "Call to a member function close() on null" exception
1 parent e5a698f commit 1c27893

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/LaravelQueueRabbitMQServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Queue\QueueManager;
66
use Illuminate\Support\ServiceProvider;
7+
use PhpAmqpLib\Connection\AMQPStreamConnection;
78
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Connectors\RabbitMQConnector;
89
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Connectors\RabbitMQConnectorSSL;
910

@@ -38,11 +39,14 @@ public function boot()
3839
}
3940

4041
$queue->stopping(function () use ($connector) {
41-
$connector->connection()->close();
42+
if ($connector->connection() instanceof AMQPStreamConnection) {
43+
$connector->connection()->close();
44+
}
4245
});
4346

4447
$queue->addConnector('rabbitmq', function () use ($connector) {
4548
return $connector;
4649
});
4750
}
4851
}
52+

0 commit comments

Comments
 (0)