STOMPCLT(1)

πŸ“¦ version 1.6, in epel 9

πŸ’… STOMPCLT πŸ’…

okay so you're looking at stompclt(1) β€” that's the manpage from User Contributed Perl Documentation, bestie, and it's literally the versatile STOMP client. buckle up πŸŽ€

✨ NAME ✨

stompclt β€” versatile STOMP client. that's it, that's the whole vibe. iconic.

🌸 SYNOPSIS 🌸

stompclt [OPTIONS]

πŸ¦‹ DESCRIPTION πŸ¦‹

stompclt is a versatile tool to interact with messaging brokers speaking STOMP and/or message queues (see Messaging::Message::Queue) on disk. no cap, it does both πŸ’–

here's the tea: it receives messages (see Messaging::Message) from an incoming module, optionally massages them (i.e. filtering and/or modifying β€” yes bestie, it's giving spa day for your messages πŸ’…), and sends them to an outgoing module. depending on which modules are used, the tool can perform different operations.

here are the supported incoming modules:

  • broker β€” connect to a messaging broker using STOMP, subscribe to one or more destinations and receive the messages sent by the broker 🐝
  • queue β€” read messages from a message queue on disk

and here are the supported outgoing modules:

  • broker β€” connect to a messaging broker using STOMP and send the messages
  • queue β€” store the messages in a message queue on disk

here are some frequently used combinations (the classic ships, iykyk):

  • incoming broker + outgoing queue β€” drain some destinations, storing the messages on disk 🌊
  • incoming queue + outgoing broker β€” (re-)send messages that have been previously stored on disk, optionally with modifications (such as altering the destination) πŸ”
  • incoming broker + outgoing broker β€” shovel messages from one broker to another 🚜

see the EXAMPLES sections for concrete examples β€” they're literally in part 2, stay tuned ✨


πŸ‘‘ OPTIONS πŸ‘‘

  • --callback-code CODE β€” execute the given Perl code on each message, see the CALLBACK section below for more information 🧚
  • --callback-data KEY=VALUE... β€” pass this data to the user supplied callback code, see the CALLBACK section below for more information
  • --callback-path PATH β€” execute the Perl code in the given file on each message, see the CALLBACK section below for more information
  • --config, --conf, --cfg PATH β€” use the given configuration file, see the CONFIGURATION FILE section below for more information. three names, one icon πŸ’…
  • --config-general KEY=VALUE... β€” use the given Config::General options when creating the configuration parser
  • --count, -c INTEGER β€” process at most the given number of messages; note: when using an incoming broker, to avoid consuming more messages, it is recommended to enable the --reliable option ⚠️ (fr fr, heed the note)
  • --daemon | --no-daemon β€” detach stompclt so that it becomes a daemon running in the background; debug, warning and error messages will get sent to syslog; this option can be negated πŸ‘»
  • --debug, -d β€” show debugging information πŸ›
  • --duration SECONDS β€” process messages during at most the given number of seconds and then stop; can be fractional ⏱️
  • --heart-beat | --no-heart-beat β€” enable STOMP 1.1 heart-beats between stompclt and the broker(s); this option can be negated πŸ’“
  • --help, -h, -? β€” show some help 🫢
  • --incoming-broker-auth STRING β€” use this authentication string (see Authen::Credential) to authenticate to the incoming broker; this option can be given multiple times πŸ”
  • --incoming-broker-connect KEY=VALUE... β€” use these options in the STOMP CONNECT frame sent to the incoming broker
  • --incoming-broker-sockopts KEY=VALUE... β€” use these socket options when connecting to the incoming broker 🧦
  • --incoming-broker-stomp-debug STRING β€” set the STOMP debug flags (see Net::STOMP::Client) when interacting with the incoming broker
  • --incoming-broker-type STRING β€” set the incoming broker type; this can be useful when using STOMP features which are broker specific
  • --incoming-broker-uri URI β€” use this connection URI (see Net::STOMP::Client) to connect to the incoming broker πŸ”—
  • --incoming-queue KEY=VALUE... β€” read incoming messages from the given message queue (see Messaging::Message::Queue)
  • --lazy | --no-lazy β€” initialize the outgoing module only after having received the first message; this option can be negated 😴
  • --list, -l β€” show all supported options πŸ“‹
  • --loop | --no-loop β€” when using an incoming message queue, loop over it; this option can be negated πŸ”„
  • --manual, -m β€” show this manual πŸ“–
  • --outgoing-broker-auth STRING β€” use this authentication string (see Authen::Credential) to authenticate to the outgoing broker; this option can be given multiple times
  • --outgoing-broker-connect KEY=VALUE... β€” use these options in the STOMP CONNECT frame sent to the outgoing broker
  • --outgoing-broker-sockopts KEY=VALUE... β€” use these socket options when connecting to the outgoing broker
  • --outgoing-broker-stomp-debug STRING β€” set the STOMP debug flags (see Net::STOMP::Client) when interacting with the outgoing broker
  • --outgoing-broker-type STRING β€” set the outgoing broker type; this can be useful when using STOMP features which are broker specific
  • --outgoing-broker-uri URI β€” use this connection URI (see Net::STOMP::Client) to connect to the outgoing broker
  • --outgoing-queue KEY=VALUE... β€” store outgoing messages into the given message queue (see Messaging::Message::Queue)
  • --pidfile PATH β€” use this pid file πŸ—‚οΈ
  • --prefetch INTEGER β€” set the prefetch value (i.e. the maximum number of messages to received without acknowledging them) on the incoming broker
  • --quit β€” tell another instance of stompclt (identified by its pid file, as specified by the --pidfile option) to quit ✌️
  • --reliable | --no-reliable β€” use STOMP features for more reliable messaging (i.e. client side acknowledgments and receipts) at the cost of less performance; this option can be negated βš–οΈ
  • --remove | --no-remove β€” when using an incoming message queue, remove the processed messages; this option can be negated πŸ—‘οΈ
  • --statistics, -s | --no-statistics β€” report statistics at the end of the execution; this option can be negated πŸ“Š
  • --status β€” get the status of another instance of stompclt (identified by its pid file, as specified by the --pidfile option); the exit code will be zero if the instance is alive and non-zero otherwise 🩺
  • --subscribe KEY=VALUE... β€” use these options in the STOMP SUBSCRIBE frame used with the incoming broker; this option can be given multiple times πŸ“¬
  • --timeout-broker SECONDS β€” use this timeout when interacting with the broker (e.g. getting receipts back); can be fractional ⏳
  • --timeout-client SECONDS β€” use this timeout for the client heart-beat; can be fractional (default: 40)
  • --timeout-connect SECONDS β€” use this timeout when connecting to the broker; can be fractional
  • --timeout-disconnect SECONDS β€” use this timeout when disconnecting from the broker; can be fractional (default: 60)
  • --timeout-flush SECONDS β€” use this timeout when attempting to send the last bytes to the broker just before disconnecting; can be fractional (default: 60) 🚿
  • --timeout-inactivity SECONDS β€” use this timeout in the incoming module to stop stompclt when no new messages have been received (aka drain mode); can be fractional
  • --timeout-linger SECONDS β€” when stopping stompclt, use this timeout to finish interacting with the broker; can be fractional
  • --timeout-server SECONDS β€” use this timeout for the server heart-beat; can be fractional (default: 10)
  • --timeout-status SECONDS β€” use this timeout when checking the status with --status; can be fractional
  • --unsubscribe KEY=VALUE... β€” use these options in the STOMP UNSUBSCRIBE frame used with the incoming broker; this option can be given multiple times and should match the --subscribe options πŸ‘‹
  • --version β€” display version information
  • --window INTEGER β€” keep at most the given number of not-yet-acknowledged messages in memory πŸͺŸ

to list all the available options in a compact form, type:

$ stompclt -l

πŸŽ€ CONFIGURATION FILE πŸŽ€

stompclt can read its options from a configuration file. for this, the Config::General module is used and the option names are the same as on the command line. for instance:

daemon = true
pidfile = /var/run/stompclt.pid
incoming-queue = path=/var/spool/stompclt
outgoing-broker-uri = stomp://broker.acme.com:6163
outgoing-broker-auth = "plain name=guest pass=guest"

alternatively, options can be nested (aesthetic ✨):

<outgoing-broker>
    uri = stomp://broker.acme.com:6163
    auth = "plain name=guest pass=guest"
</outgoing-broker>

or even:

<outgoing>
    <broker>
        uri = stomp://broker.acme.com:6163
        <auth>
            scheme = plain
            name = guest
            pass = guest
        </auth>
    </broker>
</outgoing>

and the rule you gotta remember: the options specified on the command line have precedence over the ones found in the configuration file. command line stays the main character πŸ‘‘

πŸ’– CALLBACK πŸ’–

okay so bestie, stompclt can be handed actual Perl code to run on every single message it processes. iconic, right? This is your little backstage pass, and it can be used for different purposes:

  • massaging: the code can change any part of the message, including setting or removing header fields
  • filtering: the code can decide if the message must be given to the outgoing module or not
  • displaying: the code can print any part of the message
  • copying: the code can store a copy of the message into files or message queues

To use callbacks, you gotta use the --callback-path or --callback-code option. The Perl code must provide functions with the following signature:

  • start(DATA) β€” (optional) this gets called when the program starts, with the supplied data (see the --callback-data option) as a hash reference
  • check(MESSAGE) β€” (mandatory) this gets called when the program has one message to process; it gets the message (see Messaging::Message) and must return either a message (it could be the same one or a new one) or a string describing why the message has been dropped
  • idle() β€” (optional) this gets called when the program has no message to process
  • stop() β€” (optional) this gets called when the program stops

The code can be put in a file, on the command line or in the stompclt configuration file, using the "here document" syntax.

Here is an example (to be put in the stompclt configuration file) that prints on stdout a JSON array of messages:

callback-code = <<EOF
    my($count);
    sub start ($) {
        $count = 0;
    }
    sub check ($) {
        my($msg) = @_;
        print($count++ ? "," : "[");
        print($msg->serialize(), "\n");
        return($msg);
    }
    sub stop () {
        print($count ? "]\n" : "[]\n");
    }
EOF

For simple callback code that only needs the check subroutine, it is enough to supply the "inside code". If the subroutine definition is missing, the supplied code will be wrapped with:

sub check ($) {
    my($msg) = @_;
    local *hdr = $msg->header();
    local *bdy = $msg->body_ref();
    ... your code goes here ...
    return($msg);
}

This allows for instance to remove the message-id header with something like:

$ stompclt ... --callback-code 'delete($hdr{"message-id"})'

Or to filter on message bodies with:

$ stompclt ... --callback-code 'return("skip") unless $bdy =~ /error/'

πŸ¦‹ SUBSCRIPTIONS πŸ¦‹

In the case of an incoming broker, stompclt deals with the subscriptions defined by the --subscribe option. slay.

Regardless of the --reliable option, subscriptions are always made using receipts. Also, if missing, an id header is always added.

Here is for instance how to create a named durable topic subscription using Apollo:

$ stompclt ... --subscribe 'destination=/topic/foo persistent=true id=mysub'

By default, when it finishes, stompclt does not unsubscribe. It simply disconnects from the broker and the latter will perform the necessary cleanup when terminating the STOMP connection. no cap, that's the default vibe.

If the --unsubscribe option is given, even if it is empty, stompclt will explicitly unsubscribe before disconnecting, also using receipts.

Here is for instance how to destroy, when stompclt ends, the durable topic subscription created above:

$ stompclt ... --unsubscribe 'persistent=true'

There is no need to give the subscription id in the --unsubscribe option because, by default, it comes from the matching --subscribe option. it just knows, bestie ✨


πŸŽ€ UDP SUPPORT πŸŽ€

stompclt has experimental UDP support (outgoing only). This has been tested with Apollo.

To use it, simply specify an outgoing URI that uses UDP such as:

$ stompclt ... --outgoing-broker-uri udp://broker.acme.com:6163

Features such as authentication, heart beating, reliability and socket options are not supported over UDP. so don't expect the whole menu over UDP, okay? πŸ’€


🌈 EXAMPLES 🌈

πŸš€ SENDING πŸš€

Here is an example of a configuration file for a message sender daemon (from queue to broker), forcing the persistent header to true (something which is highly recommended for reliable messaging) and setting the destination:

# define the source message queue
<incoming-queue>
    path = /var/spool/sender
</incoming-queue>
# modify the message header on the fly
callback-code = <<EOF
    $hdr{destination} = "/queue/app1.data";
    $hdr{persistent} = "true";
EOF
# define the destination broker
<outgoing-broker>
    uri = "stomp://broker.acme.com:6163"
</outgoing-broker>
# miscellaneous options
reliable = true
pidfile = /var/run/sender.pid
daemon = true
loop = true
remove = true

πŸ“ RECEIVING πŸ“

Here is an example of a configuration file for a message receiver daemon (from broker to queue):

# define the source broker
<incoming-broker>
    uri = "stomp://broker.acme.com:6163"
    <auth>
        scheme = plain
        name = receiver
        pass = secret
    </auth>
</incoming-broker>
# define the subscriptions
<subscribe>
    destination = /queue/app1.data
</subscribe>
<subscribe>
    destination = /queue/app2.data
</subscribe>
# define the destination message queue
<outgoing-queue>
    path = /var/spool/receiver
</outgoing-queue>
# miscellaneous options
pidfile = /var/run/receiver.pid
daemon = true

Here is how to use the configuration file above with some options overridden on the command line to drain the queues in the foreground:

$ stompclt --config test.conf --no-daemon --timeout-inactivity 10

🧚 SHOVELING 🧚

Here is an example of a configuration file for a message shoveler (from broker to broker), clearing some headers on the fly so that messages can be replayed safely:

# define the source broker
<incoming-broker>
    uri = "stomp://broker.acme.com:6163"
</incoming-broker>
# define the subscriptions
<subscribe>
    destination = /queue/app1.data
</subscribe>
<subscribe>
    destination = /queue/app2.data
</subscribe>
# define the destination broker
<outgoing-broker>
    uri = "stomp://dev-broker.acme.com:6163"
</outgoing-broker>
# modify the message so that it can be replayed
callback-code = <<EOF
    foreach my $name (qw(message-id timestamp expires)) {
        delete($hdr{$name});
    }
EOF

πŸ‘‘ TAPPING πŸ‘‘

Callback code can also be used to tap messages, i.e. get a copy of all messages processed by stompclt. Here is some callback code for this purpose that could for instance be merged with the shoveling code above. It also shows how to use the --callback-data option:

callback-code = <<EOF
    my($queue);
    sub start ($) {
        my($data) = @_;
        $queue = Messaging::Message::Queue->new($data);
    }
    sub check ($) {
        my($msg) = @_;
        $queue->add_message($msg);
        return($msg);
    }
EOF

Callback data must be given to specify which message queue to use:

$ stompclt --config tap.conf --callback-data "path=/tmp/tap type=DQS"

πŸ’œ SEE ALSO πŸ’œ

Authen::Credential, Config::General, Messaging::Message, Messaging::Message::Queue, Net::STOMP::Client.


🌸 AUTHOR 🌸

Lionel Cons <http://cern.ch/lionel.cons>

Copyright (C) CERN 2012-2019


and that's the whole vibe, bestie πŸ’…βœ¨ this page is STOMPCLT(1), from perl v5.32.1, dated 2019-07-27 β€” iconic manual-page energy, no cap 🫢

πŸ“¦ where this page comes from