@@ -79,11 +79,11 @@ |
||
| 79 | 79 | ->setConsumerTag($this->consumerTag) |
| 80 | 80 | ->setAutoAck($this->autoAsk) |
| 81 | 81 | ->setRouteKey($this->routeKey) |
| 82 | - ->consume(function ($message) { |
|
| 82 | + ->consume(function($message) { |
|
| 83 | 83 | /** @var Message $message */ |
| 84 | 84 | return static::processMessage($message); |
| 85 | 85 | }); |
| 86 | - } catch (InvalidArgumentException|ErrorException|Exception $exception) { |
|
| 86 | + } catch (InvalidArgumentException | ErrorException | Exception $exception) { |
|
| 87 | 87 | Log::error('AMQPMessage consume error:' . $exception->getMessage()); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -153,7 +153,9 @@ discard block |
||
| 153 | 153 | protected function makeConnection(string $name) |
| 154 | 154 | { |
| 155 | 155 | $config = $this->configuration($name); |
| 156 | - if (isset($config['host'])) $config = [$config]; |
|
| 156 | + if (isset($config['host'])) { |
|
| 157 | + $config = [$config]; |
|
| 158 | + } |
|
| 157 | 159 | return AMQPStreamConnection::create_connection($config); |
| 158 | 160 | } |
| 159 | 161 | |
@@ -429,10 +431,15 @@ discard block |
||
| 429 | 431 | |
| 430 | 432 | $channel->queue_bind($this->getQueue(), $this->getExchange()); |
| 431 | 433 | |
| 432 | - if ($message instanceof Message) $message->getMessage(); |
|
| 434 | + if ($message instanceof Message) { |
|
| 435 | + $message->getMessage(); |
|
| 436 | + } |
|
| 433 | 437 | if (!$message instanceof AMQPMessage) { |
| 434 | - if ($message instanceof Collection) $message = $message->toJson(); |
|
| 435 | - elseif (is_array($message) || is_object($message)) $message = json_encode($message); |
|
| 438 | + if ($message instanceof Collection) { |
|
| 439 | + $message = $message->toJson(); |
|
| 440 | + } elseif (is_array($message) || is_object($message)) { |
|
| 441 | + $message = json_encode($message); |
|
| 442 | + } |
|
| 436 | 443 | $message = new AMQPMessage($message, ['content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]); |
| 437 | 444 | } |
| 438 | 445 | |