Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Queue/Broker/AMQP.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,16 @@ private function withChannel(callable $callback): void
return $channel;
};

if ($this->channel == null) {
if (!$this->channel) {
$this->channel = $createChannel();
}

try {
$callback($this->channel);
} catch (\Throwable $th) {
// try to create a new connection once
unset($this->channel);
// createChannel() might throw, in that case set the channel to `null` first.
$this->channel = null;
// try creating a new connection once, if this still fails, throw the error
$this->channel = $createChannel();
$callback($this->channel);
}
Expand Down