PHP 8.4.2 Released!

Stomp::__destruct

stomp_close

(PECL stomp >= 0.1.0)

Stomp::__destruct -- stomp_closeCierra una conexión stomp

Descripción

Estilo orientado a objetos (destructor):

public Stomp::__destruct()

Estilo por procedimientos:

stomp_close(resource $link): bool

Cierra una conexión previamente abierta.

Parámetros

link

Sólo estilo por procediminetos: El identificador de enlace Stomp devuelto por stomp_connect().

Valores devueltos

Devuelve true en caso de éxito o false en caso de error.

Ejemplos

Vea stomp_connect().

add a note

User Contributed Notes 2 notes

up
0
szasz dot attila at microsec dot hu
25 days ago
Be careful, the lib does not send a DISCONNECT frame on destruction. Therefore the sessions will outlive the instance, accumulating in Artemis servers!
up
0
vanja at removethis dizyart period com
6 years ago
Isn't it a little odd to have connect/disconnect in the constructor/destructor methods?
I have a case where the connection is presumably kept alive until the PHP process ends:

<?php
class MyStompWrapper {
public function
doSend()
{
$stomp = $this->connect(); // returns Stomp Object
$stomp->send('/destination', 'message', []);
$this->disconnect($stomp);
// $stomp still exists in this scope, hence, the connection is alive
}

private function
disconnect(\Stomp $stompObj)
{
// only unsets the local $stomp pointer, does not actually disconnect
unset($stomp);
}

private function
connect():\Stomp
{
// try-catch block omitted for example brevity
return new Stomp('url', 'username', 'password');
}
}
?>

This means that, in order to handle disconnecting, I have to create and destroy the Stomp object within the same scope.
To Top