2 SPDX-FileCopyrightText: 2022 Frank Doepper
4 SPDX-License-Identifier: FSFAP
8 generic AMQP commandline tools for use with RabbitMQ
11 - publisher (`agitprop`)
12 - rpc client and worker (`plane` / `arbeite`)
14 ## konsum - an AMQP consumer.
16 **konsum** [*options*]
21 -r BINDINGKEY --bindingkey=BINDINGKEY AMQP binding key
22 -X[EXE] --execute[=EXE] Callback Script File (implies -t) (-X without arg: /usr/lib/haskell-amqp-utils/callback)
23 -a ARG --args=ARG, --arg=ARG additional argument for -X callback
24 -t[DIR] --tempdir[=DIR], --target[=DIR] tempdir (default: no file creation, -t without arg: /tmp)
25 -f INT --prefetch=INT Prefetch count. (0=unlimited, 1=off, default: 1)
26 -A --ack Toggle ack messages (default: True)
27 -R --requeuenack Toggle requeue when rejected (default: True)
28 --stream_offset=OFFSET x-stream-offset consumer argument
29 -l INT --charlimit=INT limit number of shown body chars (default: unlimited)
30 -q QUEUENAME --queue=QUEUENAME Ignore Exchange and bind to existing Queue
31 -i --simple call callback with one arg (filename) only
32 -j --cleanup Toggle remove tempfile after script call. Default False, but default True if --simple (-i)
33 -Q TEMPQNAME --qname=TEMPQNAME Name for temporary exclusive Queue
34 -x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: "")
35 -o SERVER --server=SERVER AMQP Server (default: localhost)
36 -y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
37 -p PORT --port=PORT Server Port Number (default: 5672)
38 -T --tls Toggle TLS (default: False)
39 -c CERTFILE --cert=CERTFILE TLS Client Certificate File
40 -k KEYFILE --key=KEYFILE TLS Client Private Key File
41 -U USERNAME --user=USERNAME Username for Auth
42 -P PASSWORD --pass=PASSWORD Password for Auth
43 -s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
44 -n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
45 -w SECONDS --connect_timeout=SECONDS timeout for establishing initial connection (default: 600)
49 connect to localhost with default credentials and attach to a new temp
50 queue on the default exchange:
54 Connect to a host with TLS on a custom port, authenticating with SSL
55 client certificate. On every received message a callback is spawned.
56 The message will be ACKed when the callback exits successfully. First
57 500 bytes of the message body are printed to stderr. Header infos are
58 always printed to stderr:
60 konsum -o amqp.example.com -p 5673 -T -k amqp-key.pem -c amqp-crt.pem -y vhost -x exchange -X./callback.sh -a -c -a callback.config.sh -f 2 -r binding.key.# -l 500
62 Authenticate with user and pass. Attach to an existing queue. Generate a file
65 konsum -o amqp.example.com -U user -P pass -q queue -t
67 Provide a custom CA cert for proving the server's identity via
70 $ env SYSTEM_CERTIFICATE_PATH=/etc/amqp/cacert.crt konsum -T -y vhost -x exchange -r#
72 You can have no bindings, or you can bind the queue to one or multiple exchanges + binding keys:
74 konsum -x x1 -r b1 -r b2 -x x2 -r b3
76 would bind the queue to exchange x1 with binding keys b1 and b2 and to exchange x2 with binding key b3.
80 ## agitprop - an AMQP publisher
82 **agitprop** [*options*]
85 If INPUTFILE is a file, the file is sent as a message and the program exits. If
86 INPUTFILE is a directory, the directory is watched via inotify ("hotfolder
87 mode") and every file, which is written and closed or moved in gets sent,
88 optionally only files which match one or several SUFFIXes. Optionally the file
89 name is written into a message header named HEADERNAME. Optionally
90 Content-Type and Content-Encoding headers are set via magic retrieved from file
93 Line-by-line mode sends one message per INPUTFILE line.
95 In "hotfolder mode" multiple directories can be watched and sent with distinct routingkeys.
99 -r ROUTINGKEY --routingkey=ROUTINGKEY AMQP routing key
100 -f INPUTFILE --inputfile=INPUTFILE Message input file (default: <stdin>)
101 -l --linemode Toggle line-by-line mode (default: False)
102 -C --confirm Toggle confirms (default: False)
103 --msgid=ID Message ID
104 --type=TYPE Message Type
105 --userid=USERID Message User-ID
106 --appid=APPID Message App-ID
107 --clusterid=CLUSTERID Message Cluster-ID
108 --contenttype=CONTENTTYPE Message Content-Type
109 --contentencoding=CONTENTENCODING Message Content-Encoding
110 --replyto=REPLYTO Message Reply-To
111 --prio=PRIO Message Priority
112 --corrid=CORRID Message CorrelationID
113 --exp=EXP Message Expiration
114 -h HEADER=VALUE --header=HEADER=VALUE Message Headers
115 -F HEADERNAME --fnheader=HEADERNAME Put filename into this header
116 -S SUFFIX --suffix=SUFFIX Allowed file suffixes in hotfolder mode
117 -u[DIR] --remove[=DIR], --move[=DIR] Remove (or move to DIR) sent file in hotfolder mode
118 -d --dirscan Toggle initial directory scan in hotfolder mode (default: False)
119 -m --magic Toggle setting content-type and -encoding from file contents (default: False)
120 -e --persistent Set persistent delivery
121 -E --nonpersistent Set nonpersistent delivery
122 -x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: "")
123 -o SERVER --server=SERVER AMQP Server (default: localhost)
124 -y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
125 -p PORT --port=PORT Server Port Number (default: 5672)
126 -T --tls Toggle TLS (default: False)
127 -c CERTFILE --cert=CERTFILE TLS Client Certificate File
128 -k KEYFILE --key=KEYFILE TLS Client Private Key File
129 -U USERNAME --user=USERNAME Username for Auth
130 -P PASSWORD --pass=PASSWORD Password for Auth
131 -s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
132 -n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
133 -w SECONDS --connect_timeout=SECONDS timeout for establishing initial connection (default: 600)
137 Send a message containing a file and put the filename into a fileName
140 agitprop -x amq.topic -r test -F fileName -f agitprop.hs
142 Watch two directories dir1 and dir2 and send files from dir1 with routingkey r1
143 and files from dir2 with routingkey r2, ignoring everything which is not *.txt
144 or *.zip, and set Content-Type and Content-Encoding automatically, and move all
145 sent files to subdir "done" (dir1/done and dir2/done, respectively):
147 agitprop -x amq.topic -F fileName -m -S .txt -S .zip -d -udone -r r1 -f dir1 -r r2 -f dir2
149 ## plane - an AMQP RPC client.
151 **plane** [*options*]
155 -r ROUTINGKEY, -Q ROUTINGKEY --routingkey=ROUTINGKEY, --qname=ROUTINGKEY AMQP routing key
156 -f INPUTFILE --inputfile=INPUTFILE Message input file (default: <stdin>)
157 -O OUTPUTFILE --outputfile=OUTPUTFILE Message output file (default: -)
158 -t SECONDS --rpc_timeout=SECONDS How long to wait for reply (default: 5.0)
159 --corrid=CORRID Message CorrelationID
160 --exp=EXP Message Expiration
161 -h HEADER=VALUE --header=HEADER=VALUE Message Headers
162 -l INT --charlimit=INT limit number of shown body chars (default: unlimited)
163 -x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: "")
164 -o SERVER --server=SERVER AMQP Server (default: localhost)
165 -y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
166 -p PORT --port=PORT Server Port Number (default: 5672)
167 -T --tls Toggle TLS (default: False)
168 -c CERTFILE --cert=CERTFILE TLS Client Certificate File
169 -k KEYFILE --key=KEYFILE TLS Client Private Key File
170 -U USERNAME --user=USERNAME Username for Auth
171 -P PASSWORD --pass=PASSWORD Password for Auth
172 -s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
173 -n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
174 -w SECONDS --connect_timeout=SECONDS timeout for establishing initial connection (default: 600)
178 send "ls" to a remote worker and get the result:
180 echo ls | plane -o amqp.example.com -T -k amqp.pem -c amqp.pem -y myexchange -Q rpctest
182 ## arbeite - an AMQP RPC worker.
184 **arbeite** [*options*]
188 -X[EXE] --execute[=EXE] Callback Script File (implies -t) (-X without arg: /usr/lib/haskell-amqp-utils/callback)
189 -a ARG --args=ARG, --arg=ARG additional argument for -X callback
190 -t[DIR] --tempdir[=DIR], --target[=DIR] tempdir (default: no file creation, -t without arg: /tmp)
191 -f INT --prefetch=INT Prefetch count. (0=unlimited, 1=off, default: 1)
192 -A --ack Toggle ack messages (default: True)
193 -R --requeuenack Toggle requeue when rejected (default: True)
194 -l INT --charlimit=INT limit number of shown body chars (default: unlimited)
195 -q QUEUENAME --queue=QUEUENAME Ignore Exchange and bind to existing Queue
196 -i --simple call callback with one arg (filename) only
197 -j --cleanup Toggle remove tempfile after script call. Default False, but default True if --simple (-i)
198 -Q TEMPQNAME --qname=TEMPQNAME Name for temporary exclusive Queue
199 -x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: "")
200 -o SERVER --server=SERVER AMQP Server (default: localhost)
201 -y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
202 -p PORT --port=PORT Server Port Number (default: 5672)
203 -T --tls Toggle TLS (default: False)
204 -c CERTFILE --cert=CERTFILE TLS Client Certificate File
205 -k KEYFILE --key=KEYFILE TLS Client Private Key File
206 -U USERNAME --user=USERNAME Username for Auth
207 -P PASSWORD --pass=PASSWORD Password for Auth
208 -s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
209 -n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
210 -w SECONDS --connect_timeout=SECONDS timeout for establishing initial connection (default: 600)
214 provide shell access to a remote user. Very insecure! :-)
216 arbeite -o amqp.example.com -T -k amqp.pem -c amqp.pem -y myexchange -Q rpctest -i -Xsh
221 `konsum` and `arbeite` can execute programs (`-Xprogram`) on reception of a message.
223 ### normal (old) mode
225 The callback is called with the following arguments:
230 Optionally are added:
240 Message headers are added through several -h options:
244 Any additional arguments provided by `-a arg` options are appended.
246 ### simple (new) mode
248 Wenn called with `-i` (`--simple`), the callback is called with only the filename
249 as argument. Any additional arguments provided by `-a arg` options are prepended.
253 The arguments provided in normal (old) mode are also available as environment
254 variables in both modes in the callback:
267 And the remaining message properties, too:
279 Message headers, if any, are available as
288 ## code, bugs, contribution, etc.
290 - project page: https://sr.ht/~woffs/haskell-amqp-utils/
291 - mailing list: https://lists.sr.ht/~woffs/public-inbox
292 - todo list / bug tracker: https://todo.sr.ht/~woffs/haskell-amqp-utils
295 - git://woffs.de/git/fd/haskell-amqp-utils.git
296 - https://woffs.de/git/fd/haskell-amqp-utils.git
297 - https://git.sr.ht/~woffs/haskell-amqp-utils
298 - Repology: https://repology.org/project/haskell:amqp-utils/packages
299 - Hackage: https://hackage.haskell.org/package/amqp-utils
300 - Stackage: https://www.stackage.org/package/amqp-utils