Net::ST...eartBeat(3)
okay so bestie, welcome to the Net::ST...eartBeat(3) page β the User Contributed Perl Documentation one β and weβre gonna make it make sense πβ¨
β¨ NAME β¨
Net::STOMP::Client::HeartBeat β heart-beat support for Net::STOMP::Client, no cap π
π¦ SYNOPSIS π¦
bestie, hereβs the whole setup in code, exactly as it appears:
use Net::STOMP::Client;
$stomp = Net::STOMP::Client->new(host => "127.0.0.1", port => 61613);
...
# can set the desired configuration only _before_ connect()
# the client can send heart-beats every 5 seconds
$stomp->client_heart_beat(5);
# the server should send heart-beats every 10 seconds
$stomp->server_heart_beat(10);
...
$stomp->connect();
...
# can get the negotiated configuration only _after_ connect()
printf("negotiated heart-beats: client=%.3f server=%.3f\n",
$stomp->client_heart_beat(), $stomp->server_heart_beat());
π DESCRIPTION π
This module handles STOMP heart-beat negotiation. It is used internally by Net::STOMP::Client and should not be directly used elsewhere.
lowkey important: itβs internal backstage magic π§, so pls donβt use it directly elsewhere β thatβs the vibe, fr fr π
π METHODS π
This module provides the following methods to Net::STOMP::Client:
client_heart_beat([VALUE])β get/set the client heart-beatserver_heart_beat([VALUE])β get/set the server heart-beatlast_received()β get the time at which data was last received, i.e. read from the network socketlast_sent()β get the time at which data was last sent, i.e. written to the network socketbeat([OPTIONS])β send aNOOPframe (using thenoop()method) unless the last sent time is recent enough with regard to the client heart-beat settings
For consistency with other Perl modules (for instance Time::HiRes), time is always expressed as a fractional number of seconds. periodt β±οΈ
π HEART-BEATING π
Starting with STOMP 1.1, each end of a STOMP connection can check if the other end is alive via heart-beating.
In order to use heart-beating (which is disabled by default), the client must specify what it wants before sending the CONNECT frame. This can be done using the client_heart_beat and server_heart_beat options of the new() method or, this is equivalent, the client_heart_beat() and server_heart_beat() methods on the Net::STOMP::Client object.
After having received the CONNECTED frame, the client_heart_beat() and server_heart_beat() methods can be used to get the negotiated values.
To prove that it is alive, the client just needs to call the beat() method when convenient.
To check if the server is alive, the client just needs to compare the current time and what is returned by the last_received() and server_heart_beat() methods. For instance:
$delta = $stomp->server_heart_beat();
if ($delta) {
$inactivity = Time::HiRes::time() - $stomp->last_received();
printf("server looks dead!\n") if $inactivity > $delta;
}
π SEE ALSO π
go check out Net::STOMP::Client, Time::HiRes. iykyk π
π AUTHOR π
Lionel Cons <http://cern.ch/lionel.cons>
Copyright (C) CERN 2010-2017
mwah π this page was brought to you by perl v5.32.1, dated 2019-07-26, and the Net::ST...eartBeat(3) manual-page energy πβ¨
π¦ where this page comes from
- epel 9: perl-Net-STOMP-Client 2.3-10.el9 Β· GPL+ or Artistic
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms