Closed jackzhiii closed 4 years ago
when I read a article(url: https://www.cloudamqp.com/blog/2018-01-19-part4-rabbitmq-13-common-errors.html), I get a advice of that "Don’t open and close connections or channels repeatedly"
But I read this library source code
public function publish($routing, $message, array $properties = []) { $properties['routing'] = $routing; /* @var Publisher $publisher */ $publisher = app()->make('Bschmitt\Amqp\Publisher'); $publisher ->mergeProperties($properties) ->setup(); if (is_string($message)) { $message = new Message($message, ['content_type' => 'text/plain', 'delivery_mode' => 2]); } $publisher->publish($routing, $message); Request::shutdown($publisher->getChannel(), $publisher->getConnection()); }
I see than close connection and channel every time when call publish method. relevant code
public static function shutdown(AMQPChannel $channel, AMQPStreamConnection $connection) { $channel->close(); $connection->close(); }
So, it is a bad practice for this way of publish message implements?
As far as I'm concerned you should always closing connections because php run request wise. Would even be worse to let the connection open.
Not sure about the newest php meta/versions though.
when I read a article(url: https://www.cloudamqp.com/blog/2018-01-19-part4-rabbitmq-13-common-errors.html), I get a advice of that "Don’t open and close connections or channels repeatedly"
But I read this library source code
I see than close connection and channel every time when call publish method. relevant code
So, it is a bad practice for this way of publish message implements?