-
Notifications
You must be signed in to change notification settings - Fork 0
/
stompclt.html
714 lines (521 loc) · 23.3 KB
/
stompclt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
<html><head><title>stompclt</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
</head>
<body class='pod'>
<!--
generated by Pod::Simple::HTML v3.28,
using Pod::Simple::PullParser v3.28,
under Perl v5.016003 at Thu Oct 28 08:38:19 2021 GMT.
If you want to change this HTML document, you probably shouldn't do that
by changing it directly. Instead, see about changing the calling options
to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
then reconverting this document from the Pod source.
When in doubt, email the author of Pod::Simple::HTML for advice.
See 'perldoc Pod::Simple::HTML' for more info.
-->
<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>
<h1><a class='u'
name="NAME"
>NAME</a></h1>
<p>stompclt - versatile STOMP client</p>
<h1><a class='u'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<p><b>stompclt</b> [<i>OPTIONS</i>]</p>
<h1><a class='u'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p><b>stompclt</b> is a versatile tool to interact with messaging brokers speaking STOMP and/or message queues (see <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage%3A%3AQueue" class="podlinkpod"
>Messaging::Message::Queue</a>) on disk.</p>
<p>It receives messages (see <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage" class="podlinkpod"
>Messaging::Message</a>) from an incoming module,
optionally massaging them (i.e.
filtering and/or modifying),
and sends them to an outgoing module.
Depending on which modules are used,
the tool can perform different operations.</p>
<p>Here are the supported incoming modules:</p>
<ul>
<li>broker: connect to a messaging broker using STOMP,
subscribe to one or more destinations and receive the messages sent by the broker</li>
<li>queue: read messages from a message queue on disk</li>
</ul>
<p>Here are the supported outgoing modules:</p>
<ul>
<li>broker: connect to a messaging broker using STOMP and send the messages</li>
<li>queue: store the messages in a message queue on disk</li>
</ul>
<p>Here are some frequently used combinations:</p>
<ul>
<li><i>incoming broker + outgoing queue</i>: drain some destinations,
storing the messages on disk</li>
<li><i>incoming queue + outgoing broker</i>: (re-)send messages that have been previously stored on disk,
optionally with modifications (such as altering the destination)</li>
<li><i>incoming broker + outgoing broker</i>: shovel messages from one broker to another</li>
</ul>
<p>See the <a href="#EXAMPLES" class="podlinkpod"
>"EXAMPLES"</a> sections for concrete examples.</p>
<h1><a class='u'
name="OPTIONS"
>OPTIONS</a></h1>
<dl>
<dt><a name="--callback-code_CODE"
><b>--callback-code</b> <i>CODE</i></a></dt>
<dd>
<p>execute the given Perl code on each message,
see the <a href="#CALLBACK" class="podlinkpod"
>"CALLBACK"</a> section below for more information</p>
<dt><a name="--callback-data_KEY=VALUE..."
><b>--callback-data</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>pass this data to the user supplied callback code,
see the <a href="#CALLBACK" class="podlinkpod"
>"CALLBACK"</a> section below for more information</p>
<dt><a name="--callback-path_PATH"
><b>--callback-path</b> <i>PATH</i></a></dt>
<dd>
<p>execute the Perl code in the given file on each message,
see the <a href="#CALLBACK" class="podlinkpod"
>"CALLBACK"</a> section below for more information</p>
<dt><a name="--config,_--conf,_--cfg_PATH"
><b>--config</b>,
<b>--conf</b>,
<b>--cfg</b> <i>PATH</i></a></dt>
<dd>
<p>use the given configuration file,
see the <a href="#CONFIGURATION_FILE" class="podlinkpod"
>"CONFIGURATION FILE"</a> section below for more information</p>
<dt><a name="--config-general_KEY=VALUE..."
><b>--config-general</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use the given <a href="http://search.cpan.org/perldoc?Config%3A%3AGeneral" class="podlinkpod"
>Config::General</a> options when creating the configuration parser</p>
<dt><a name="--count,_-c_INTEGER"
><b>--count</b>,
<b>-c</b> <i>INTEGER</i></a></dt>
<dd>
<p>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 <b>--reliable</b> option</p>
<dt><a name="--daemon_|_--no-daemon"
><b>--daemon</b> | <b>--no-daemon</b></a></dt>
<dd>
<p>detach <b>stompclt</b> 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</p>
<dt><a name="--debug,_-d"
><b>--debug</b>,
<b>-d</b></a></dt>
<dd>
<p>show debugging information</p>
<dt><a name="--duration_SECONDS"
><b>--duration</b> <i>SECONDS</i></a></dt>
<dd>
<p>process messages during at most the given number of seconds and then stop; can be fractional</p>
<dt><a name="--heart-beat_|_--no-heart-beat"
><b>--heart-beat</b> | <b>--no-heart-beat</b></a></dt>
<dd>
<p>enable STOMP 1.1 heart-beats between <b>stompclt</b> and the broker(s); this option can be negated</p>
<dt><a name="--help,_-h,_-?"
><b>--help</b>,
<b>-h</b>,
<b>-?</b></a></dt>
<dd>
<p>show some help</p>
<dt><a name="--incoming-broker-auth_STRING"
><b>--incoming-broker-auth</b> <i>STRING</i></a></dt>
<dd>
<p>use this authentication string (see <a href="http://search.cpan.org/perldoc?Authen%3A%3ACredential" class="podlinkpod"
>Authen::Credential</a>) to authenticate to the incoming broker; this option can be given multiple times</p>
<dt><a name="--incoming-broker-connect_KEY=VALUE..."
><b>--incoming-broker-connect</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these options in the STOMP CONNECT frame sent to the incoming broker</p>
<dt><a name="--incoming-broker-sockopts_KEY=VALUE..."
><b>--incoming-broker-sockopts</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these socket options when connecting to the incoming broker</p>
<dt><a name="--incoming-broker-stomp-debug_STRING"
><b>--incoming-broker-stomp-debug</b> <i>STRING</i></a></dt>
<dd>
<p>set the STOMP debug flags (see <a href="http://search.cpan.org/perldoc?Net%3A%3ASTOMP%3A%3AClient" class="podlinkpod"
>Net::STOMP::Client</a>) when interacting with the incoming broker</p>
<dt><a name="--incoming-broker-type_STRING"
><b>--incoming-broker-type</b> <i>STRING</i></a></dt>
<dd>
<p>set the incoming broker type; this can be useful when using STOMP features which are broker specific</p>
<dt><a name="--incoming-broker-uri_URI"
><b>--incoming-broker-uri</b> <i>URI</i></a></dt>
<dd>
<p>use this connection URI (see <a href="http://search.cpan.org/perldoc?Net%3A%3ASTOMP%3A%3AClient" class="podlinkpod"
>Net::STOMP::Client</a>) to connect to the incoming broker</p>
<dt><a name="--incoming-queue_KEY=VALUE..."
><b>--incoming-queue</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>read incoming messages from the given message queue (see <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage%3A%3AQueue" class="podlinkpod"
>Messaging::Message::Queue</a>)</p>
<dt><a name="--lazy_|_--no-lazy"
><b>--lazy</b> | <b>--no-lazy</b></a></dt>
<dd>
<p>initialize the outgoing module only after having received the first message; this option can be negated</p>
<dt><a name="--list,_-l"
><b>--list</b>,
<b>-l</b></a></dt>
<dd>
<p>show all supported options</p>
<dt><a name="--loop_|_--no-loop"
><b>--loop</b> | <b>--no-loop</b></a></dt>
<dd>
<p>when using an incoming message queue,
loop over it; this option can be negated</p>
<dt><a name="--manual,_-m"
><b>--manual</b>,
<b>-m</b></a></dt>
<dd>
<p>show this manual</p>
<dt><a name="--outgoing-broker-auth_STRING"
><b>--outgoing-broker-auth</b> <i>STRING</i></a></dt>
<dd>
<p>use this authentication string (see <a href="http://search.cpan.org/perldoc?Authen%3A%3ACredential" class="podlinkpod"
>Authen::Credential</a>) to authenticate to the outgoing broker; this option can be given multiple times</p>
<dt><a name="--outgoing-broker-connect_KEY=VALUE..."
><b>--outgoing-broker-connect</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these options in the STOMP CONNECT frame sent to the outgoing broker</p>
<dt><a name="--outgoing-broker-sockopts_KEY=VALUE..."
><b>--outgoing-broker-sockopts</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these socket options when connecting to the outgoing broker</p>
<dt><a name="--outgoing-broker-stomp-debug_STRING"
><b>--outgoing-broker-stomp-debug</b> <i>STRING</i></a></dt>
<dd>
<p>set the STOMP debug flags (see <a href="http://search.cpan.org/perldoc?Net%3A%3ASTOMP%3A%3AClient" class="podlinkpod"
>Net::STOMP::Client</a>) when interacting with the outgoing broker</p>
<dt><a name="--outgoing-broker-type_STRING"
><b>--outgoing-broker-type</b> <i>STRING</i></a></dt>
<dd>
<p>set the outgoing broker type; this can be useful when using STOMP features which are broker specific</p>
<dt><a name="--outgoing-broker-uri_URI"
><b>--outgoing-broker-uri</b> <i>URI</i></a></dt>
<dd>
<p>use this connection URI (see <a href="http://search.cpan.org/perldoc?Net%3A%3ASTOMP%3A%3AClient" class="podlinkpod"
>Net::STOMP::Client</a>) to connect to the outgoing broker</p>
<dt><a name="--outgoing-queue_KEY=VALUE..."
><b>--outgoing-queue</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>store outgoing messages into the given message queue (see <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage%3A%3AQueue" class="podlinkpod"
>Messaging::Message::Queue</a>)</p>
<dt><a name="--pidfile_PATH"
><b>--pidfile</b> <i>PATH</i></a></dt>
<dd>
<p>use this pid file</p>
<dt><a name="--prefetch_INTEGER"
><b>--prefetch</b> <i>INTEGER</i></a></dt>
<dd>
<p>set the prefetch value (i.e.
the maximum number of messages to received without acknowledging them) on the incoming broker</p>
<dt><a name="--quit"
><b>--quit</b></a></dt>
<dd>
<p>tell another instance of <b>stompclt</b> (identified by its pid file,
as specified by the <b>--pidfile</b> option) to quit</p>
<dt><a name="--reliable_|_--no-reliable"
><b>--reliable</b> | <b>--no-reliable</b></a></dt>
<dd>
<p>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</p>
<dt><a name="--remove_|_--no-remove"
><b>--remove</b> | <b>--no-remove</b></a></dt>
<dd>
<p>when using an incoming message queue,
remove the processed messages; this option can be negated</p>
<dt><a name="--statistics,_-s_|_--no-statistics"
><b>--statistics</b>,
<b>-s</b> | <b>--no-statistics</b></a></dt>
<dd>
<p>report statistics at the end of the execution; this option can be negated</p>
<dt><a name="--status"
><b>--status</b></a></dt>
<dd>
<p>get the status of another instance of <b>stompclt</b> (identified by its pid file,
as specified by the <b>--pidfile</b> option); the exit code will be zero if the instance is alive and non-zero otherwise</p>
<dt><a name="--subscribe_KEY=VALUE..."
><b>--subscribe</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these options in the STOMP SUBSCRIBE frame used with the incoming broker; this option can be given multiple times</p>
<dt><a name="--timeout-broker_SECONDS"
><b>--timeout-broker</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout when interacting with the broker (e.g.
getting receipts back); can be fractional</p>
<dt><a name="--timeout-client_SECONDS"
><b>--timeout-client</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout for the client heart-beat; can be fractional (default: 40)</p>
<dt><a name="--timeout-connect_SECONDS"
><b>--timeout-connect</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout when connecting to the broker; can be fractional</p>
<dt><a name="--timeout-disconnect_SECONDS"
><b>--timeout-disconnect</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout when disconnecting from the broker; can be fractional (default: 60)</p>
<dt><a name="--timeout-flush_SECONDS"
><b>--timeout-flush</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout when attempting to send the last bytes to the broker just before disconnecting; can be fractional (default: 60)</p>
<dt><a name="--timeout-inactivity_SECONDS"
><b>--timeout-inactivity</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout in the incoming module to stop <b>stompclt</b> when no new messages have been received (aka drain mode); can be fractional</p>
<dt><a name="--timeout-linger_SECONDS"
><b>--timeout-linger</b> <i>SECONDS</i></a></dt>
<dd>
<p>when stopping <b>stompclt</b>,
use this timeout to finish interacting with the broker; can be fractional</p>
<dt><a name="--timeout-server_SECONDS"
><b>--timeout-server</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout for the server heart-beat; can be fractional (default: 10)</p>
<dt><a name="--timeout-status_SECONDS"
><b>--timeout-status</b> <i>SECONDS</i></a></dt>
<dd>
<p>use this timeout when checking the status with <b>--status</b>; can be fractional</p>
<dt><a name="--unsubscribe_KEY=VALUE..."
><b>--unsubscribe</b> <i>KEY=VALUE...</i></a></dt>
<dd>
<p>use these options in the STOMP UNSUBSCRIBE frame used with the incoming broker; this option can be given multiple times and should match the <b>--subscribe</b> options</p>
<dt><a name="--version"
><b>--version</b></a></dt>
<dd>
<p>display version information</p>
<dt><a name="--window_INTEGER"
><b>--window</b> <i>INTEGER</i></a></dt>
<dd>
<p>keep at most the given number of not-yet-acknowledged messages in memory</p>
</dd>
</dl>
<p>To list all the available options in a compact form,
type:</p>
<pre> $ stompclt -l</pre>
<h1><a class='u'
name="CONFIGURATION_FILE"
>CONFIGURATION FILE</a></h1>
<p><b>stompclt</b> can read its options from a configuration file. For this, the <a href="http://search.cpan.org/perldoc?Config%3A%3AGeneral" class="podlinkpod"
>Config::General</a> module is used and the option names are the same as on the command line. For instance:</p>
<pre> 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"</pre>
<p>Alternatively, options can be nested:</p>
<pre> <outgoing-broker>
uri = stomp://broker.acme.com:6163
auth = "plain name=guest pass=guest"
</outgoing-broker></pre>
<p>Or even:</p>
<pre> <outgoing>
<broker>
uri = stomp://broker.acme.com:6163
<auth>
scheme = plain
name = guest
pass = guest
</auth>
</broker>
</outgoing></pre>
<p>The options specified on the command line have precedence over the ones found in the configuration file.</p>
<h1><a class='u'
name="CALLBACK"
>CALLBACK</a></h1>
<p><b>stompclt</b> can be given Perl code to execute on all processed messages. This can be used for different purposes:</p>
<ul>
<li>massaging: the code can change any part of the message, including setting or removing header fields</li>
<li>filtering: the code can decide if the message must be given to the outgoing module or not</li>
<li>displaying: the code can print any part of the message</li>
<li>copying: the code can store a copy of the message into files or message queues</li>
</ul>
<p>To use callbacks, the <b>--callback-path</b> or <b>--callback-code</b> option must be used. The Perl code must provide functions with the following signature:</p>
<dl>
<dt><a name="start(DATA)"
>start(DATA)</a></dt>
<dd>
<p>(optional) this will be called when the program starts, with the supplied data (see the <b>--callback-data</b> option) as a hash reference</p>
<dt><a name="check(MESSAGE)"
>check(MESSAGE)</a></dt>
<dd>
<p>(mandatory) this will be called when the program has one message to process; it will be given the message (see <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage" class="podlinkpod"
>Messaging::Message</a>) 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</p>
<dt><a name="idle()"
>idle()</a></dt>
<dd>
<p>(optional) this will be called when the program has no message to process</p>
<dt><a name="stop()"
>stop()</a></dt>
<dd>
<p>(optional) this will be called when the program stops</p>
</dd>
</dl>
<p>The code can be put in a file, on the command line or in the <b>stompclt</b> configuration file, using the "here document" syntax.</p>
<p>Here is an example (to be put in the <b>stompclt</b> configuration file) that prints on stdout a JSON array of messages:</p>
<pre> 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</pre>
<p>For simple callback code that only needs the <code>check</code> subroutine, it is enough to supply the "inside code". If the subroutine definition is missing, the supplied code will be wrapped with:</p>
<pre> sub check ($) {
my($msg) = @_;
local *hdr = $msg->header();
local *bdy = $msg->body_ref();
... your code goes here ...
return($msg);
}</pre>
<p>This allows for instance to remove the <code>message-id</code> header with something like:</p>
<pre> $ stompclt ... --callback-code 'delete($hdr{"message-id"})'</pre>
<p>Or to filter on message bodies with:</p>
<pre> $ stompclt ... --callback-code 'return("skip") unless $bdy =~ /error/'</pre>
<h1><a class='u'
name="SUBSCRIPTIONS"
>SUBSCRIPTIONS</a></h1>
<p>In the case of an incoming broker, <b>stompclt</b> deals with the subscriptions defined by the <b>--subscribe</b> option.</p>
<p>Regardless of the <b>--reliable</b> option, subscriptions are always made using receipts. Also, if missing, an <code>id</code> header is always added.</p>
<p>Here is for instance how to create a named durable topic subscription using Apollo:</p>
<pre> $ stompclt ... --subscribe 'destination=/topic/foo persistent=true id=mysub'</pre>
<p>By default, when it finishes, <b>stompclt</b> does not unsubscribe. It simply disconnects from the broker and the latter will perform the necessary cleanup when terminating the STOMP connection.</p>
<p>If the <b>--unsubscribe</b> option is given, even if it is empty, <b>stompclt</b> will explicitly unsubscribe before disconnecting, also using receipts.</p>
<p>Here is for instance how to destroy, when <b>stompclt</b> ends, the durable topic subscription created above:</p>
<pre> $ stompclt ... --unsubscribe 'persistent=true'</pre>
<p>There is no need to give the subscription <code>id</code> in the <b>--unsubscribe</b> option because, by default, it comes from the matching <b>--subscribe</b> option.</p>
<h1><a class='u'
name="UDP_SUPPORT"
>UDP SUPPORT</a></h1>
<p><b>stompclt</b> has experimental UDP support (outgoing only). This has been tested with Apollo.</p>
<p>To use it, simply specify an outgoing URI that uses UDP such as:</p>
<pre> $ stompclt ... --outgoing-broker-uri udp://broker.acme.com:6163</pre>
<p>Features such as authentication, heart beating, reliability and socket options are not supported over UDP.</p>
<h1><a class='u'
name="EXAMPLES"
>EXAMPLES</a></h1>
<h2><a class='u'
name="SENDING"
>SENDING</a></h2>
<p>Here is an example of a configuration file for a message sender daemon (from queue to broker), forcing the <code>persistent</code> header to <code>true</code> (something which is highly recommended for reliable messaging) and setting the destination:</p>
<pre> # 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</pre>
<h2><a class='u'
name="RECEIVING"
>RECEIVING</a></h2>
<p>Here is an example of a configuration file for a message receiver daemon (from broker to queue):</p>
<pre> # 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</pre>
<p>Here is how to use the configuration file above with some options overridden on the command line to drain the queues in the foreground:</p>
<pre> $ stompclt --config test.conf --no-daemon --timeout-inactivity 10</pre>
<h2><a class='u'
name="SHOVELING"
>SHOVELING</a></h2>
<p>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:</p>
<pre> # 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</pre>
<h2><a class='u'
name="TAPPING"
>TAPPING</a></h2>
<p>Callback code can also be used to tap messages, i.e. get a copy of all messages processed by <b>stompclt</b>. 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 <b>--callback-data</b> option:</p>
<pre> 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</pre>
<p>Callback data must be given to specify which message queue to use:</p>
<pre> $ stompclt --config tap.conf --callback-data "path=/tmp/tap type=DQS"</pre>
<h1><a class='u'
name="SEE_ALSO"
>SEE ALSO</a></h1>
<p><a href="http://search.cpan.org/perldoc?Authen%3A%3ACredential" class="podlinkpod"
>Authen::Credential</a>, <a href="http://search.cpan.org/perldoc?Config%3A%3AGeneral" class="podlinkpod"
>Config::General</a>, <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage" class="podlinkpod"
>Messaging::Message</a>, <a href="http://search.cpan.org/perldoc?Messaging%3A%3AMessage%3A%3AQueue" class="podlinkpod"
>Messaging::Message::Queue</a>, <a href="http://search.cpan.org/perldoc?Net%3A%3ASTOMP%3A%3AClient" class="podlinkpod"
>Net::STOMP::Client</a>.</p>
<h1><a class='u'
name="AUTHOR"
>AUTHOR</a></h1>
<p>Lionel Cons <a href="http://cern.ch/lionel.cons" class="podlinkurl"
>http://cern.ch/lionel.cons</a></p>
<p>Copyright (C) CERN 2012-2024</p>
<!-- end doc -->
</body></html>