Skip to content

Commit

Permalink
Unwrap try...catch
Browse files Browse the repository at this point in the history
  • Loading branch information
JPHall-DLS committed Sep 10, 2024
1 parent a62fe46 commit 2deb2f7
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions api/src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ function __construct($host, $port, $username, $password)

function send($vhost, array $message)
{
try {
$connection = new AMQPStreamConnection($this->host, $this->port, $this->username, $this->password);
$channel = $connection->channel();
$connection = new AMQPStreamConnection($this->host, $this->port, $this->username, $this->password);
$channel = $connection->channel();

$msg = new AMQPMessage(
json_encode($message, JSON_UNESCAPED_SLASHES)
);
$msg = new AMQPMessage(
json_encode($message, JSON_UNESCAPED_SLASHES)
);

$channel->basic_publish($msg, '', $vhost);
$channel->basic_publish($msg, '', $vhost);

$channel->close();
$connection->close();
} catch (AMQPException $e) {
/** @noinspection PhpUnhandledExceptionInspection */

throw $e;
}
$channel->close();
$connection->close();
}
}

0 comments on commit 2deb2f7

Please sign in to comment.