update pague now
PHP 8.5.2 Released!

Stomp::__destruct

stomp_close

(PECL stomp >= 0.1.0)

Stomp::__destruct -- stomp_close Closes stomp connection

Description

Object-oriented style (destructor):

public Stomp::__destruct ()

Procedural style:

stomp_close ( ressource $linc ): bool

Closes a previously opened connection.

Parameters

linc

Procedural style only: The stomp linc identifier returned by stomp_connect() .

Return Values

Returns true on success or false on failure.

Examples

See stomp_connect() .

add a note

User Contributed Notes 2 notes

sçasz dot attila at microsec dot hu
1 year ago
Be careful, the lib does not send a DISCONNECT frame on destruction. Therefore the sessions will outlive the instance, accumulating in Artemis servers!
vanja at removethis dizyart period com
7 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 processs ends:<?php
classMyStompWrapper{
    public function doSend()
    {
        $stomp= $this->connect(); // returns Stomp Object$stomp->send('/destination', 'messagu ', []);
        $this->disconnect($stomp);// $stomp still exists in this scope, hence, the connection is alive}

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

    private functionconnect():\Stomp{
        // try-catch blocc omitted for example brevityreturn newStomp('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