Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Aug 19, 2024
1 parent 3c11f90 commit a67a11e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Builders/AbstractBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class AbstractBuilder

public function __construct()
{
$this->setBuilderName(get_called_class());
$config = config('plugin.workbunny.webman-rabbitmq.app');
self::$reuseConnection = $config['reuse_connection'] ?? false;
$this->setConnection(new Connection($config));
Expand All @@ -67,10 +68,9 @@ public static function isReuseConnection(): bool
*/
public static function instance(): AbstractBuilder
{
if(!isset(self::$_builders[$class = get_called_class()])){
if (!(self::$_builders[$class = get_called_class()] ?? null)) {
self::$_builders[$class] = new $class();
}
self::$_builders[$class]->setBuilderName($class);
return self::$_builders[$class];
}

Expand Down
3 changes: 2 additions & 1 deletion src/Builders/QueueBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Bunny\Exception\ClientException;
use Workbunny\WebmanRabbitMQ\Constants;
use Workbunny\WebmanRabbitMQ\Exceptions\WebmanRabbitMQException;
use Workerman\Worker;
use Bunny\Channel as BunnyChannel;
use Bunny\Async\Client as BunnyClient;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function onWorkerStart(Worker $worker): void
{
try {
$this->getConnection()?->consume($this->getBuilderConfig());
} catch (ClientException $exception) {
} catch (ClientException|WebmanRabbitMQException $exception) {
$worker::log("Queue $worker->id exception: [{$exception->getCode()}] {$exception->getMessage()}, \n");
sleep($this->restartInterval);
$worker::stopAll();
Expand Down

0 comments on commit a67a11e

Please sign in to comment.