Be careful, the lib does not send a DISCONNECT frame on destruction. Therefore the sessions will outlive the instance, accumulating in Artemis servers!
(PECL stomp >= 0.1.0)
Stomp::__destruct -- stomp_close — Closes stomp connection
Object-oriented style (destructor):
Procedural style:
Closes a previously opened connection.
See stomp_connect().
Be careful, the lib does not send a DISCONNECT frame on destruction. Therefore the sessions will outlive the instance, accumulating in Artemis servers!
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.
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant