bschmitt / laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages
MIT License
268 stars 86 forks source link

Use built-in close-on-destruct method on connection #40

Closed emil-nasso closed 6 years ago

emil-nasso commented 6 years ago

Instead of relying on shutdown functions, use the built-in set_close_on_destruct method on the connection. This method closes the connection in a safe way.

Using a shutdown function and calling close on the channel and connection is problematic when the server closes the connection (or there is a problem with the network connection. In that case, the following will happen:

Letting php-amqplib close the connection solves this problem as it does it in a safe way, without throwing exceptions.

bschmitt commented 6 years ago

@emil-nasso thank you very much, maybe you want to support this project? #41