我需要为队列创建一个析构函数。因此,如果系统突然崩溃,析构函数将被调用。只有当队列尚未关闭时,析构函数才会关闭所有队列和连接。
有没有办法检查队列是否存在或类似的东西?到目前为止,我找不到它。
这是我的代码:
public function __destruct(){
# add if queue exists here
$this->channels->close();
$this->connection->close();
echo 'Connection closed.';
}