Skip to content

Commit

Permalink
fixed #18
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Nov 19, 2023
1 parent e6cea7c commit a88ba72
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,24 @@ public function syncPublish(BuilderConfig $config, bool $close = false): bool
$config->getQueue(), $config->getExchange(), $config->getRoutingKey(), $config->isNowait(),
$config->getArguments()
);
}catch (Throwable $throwable){
} catch (Throwable $throwable){
if($this->getErrorCallback()){\call_user_func($this->getErrorCallback(), $throwable, $this);}
$this->close($this->getSyncClient(), $throwable);
return false;
}
}

return $channel->publish(
$config->getBody(), $config->getHeaders(), $config->getExchange(), $config->getRoutingKey(),
$config->isMandatory(), $config->isImmediate()
)->then(function () use ($close) {
if($close) {$this->close($this->getAsyncClient());}
}, function (Throwable $throwable) {
try {
$res = (bool)$channel->publish(
$config->getBody(), $config->getHeaders(), $config->getExchange(), $config->getRoutingKey(),
$config->isMandatory(), $config->isImmediate()
);
if($close) {$this->close($this->getSyncClient());}
return $res;
} catch (Throwable $throwable){
if($this->getErrorCallback()){\call_user_func($this->getErrorCallback(), $throwable, $this);}
$this->close($this->getSyncClient(), $throwable);
})->done();
return false;
}
}

/**
Expand Down

0 comments on commit a88ba72

Please sign in to comment.