haskell-amqp-utils
generic Haskell AMQP commandline tools for use with RabbitMQ
Overview
The package contains 2 binaries for commandline use.
- konsum, a generic consumer
- agitprop, a generic publisher
konsum
usage
konsum [options]
Options:
-r BINDINGKEY --bindingkey=BINDINGKEY AMQP binding key (default: #)
-X[EXE] --execute[=EXE] Callback Script File (implies -t) (-X without arg: /usr/lib/haskell-amqp-utils/callback)
-a ARG --args=ARG additional argument for -X callback
-l INT --charlimit=INT limit number of shown body chars (default: unlimited)
-t[DIR] --tempdir[=DIR], --target[=DIR] tempdir (default: no file creation, -t without arg: /tmp)
-f INT --prefetch=INT Prefetch count. (0=unlimited, 1=off, default: 1)
-o SERVER --server=SERVER AMQP Server (default: localhost)
-y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
-x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: default)
-Q TEMPQNAME --qname=TEMPQNAME Name for temporary exclusive Queue
-p PORT --port=PORT Server Port Number (default: 5672)
-T --tls Toggle TLS (default: False)
-q QUEUENAME --queue=QUEUENAME Ignore Exchange and bind to existing Queue
-c CERTFILE --cert=CERTFILE TLS Client Certificate File
-k KEYFILE --key=KEYFILE TLS Client Private Key File
-U USERNAME --user=USERNAME Username for Auth
-P PASSWORD --pass=PASSWORD Password for Auth
-s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
-n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
examples
connect to localhost with default credentials and attach to a new temp
queue on exchange "default":
./konsum
Connect to a host with TLS on a custom port, authenticating with SSL
client certificate. On every received message a callback is spawned.
The message will be ACKed when the callback exits successfully. First
500 bytes of the message body are printed to stdout. Header infos are
always printed to stdout:
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 routing.key.# -l 500
Authenticate with user and pass. Generate a file for every message:
konsum -o amqp.example.com -U user -P pass -q queue -t
Provide a custom CA cert for proving the server's identity via
enviroment:
$ env SYSTEM_CERTIFICATE_PATH=/etc/amqp/cacert.crt ./konsum -T -y vhost -x exchange
Stop with ^C
agitprop
usage
agitprop [options]
Options:
-r ROUTINGKEY --routingkey=ROUTINGKEY AMQP routing key
-f INPUTFILE --inputfile=INPUTFILE Message input file (default: /dev/stdin)
-l --linemode Toggle line-by-line mode (default: False)
-C --confirm Toggle confirms (default: False)
--msgid=ID Message ID
--type=TYPE Message Type
--userid=USERID Message User-ID
--appid=APPID Message App-ID
--clusterid=CLUSTERID Message Cluster-ID
--contenttype=CONTENTTYPE Message Content-Type
--contentencoding=CONTENTENCODING Message Content-Encoding
--replyto=REPLYTO Message Reply-To
--prio=PRIO Message Priority
--corrid=CORRID Message CorrelationID
--exp=EXP Message Expiration
-h HEADER=VALUE --header=HEADER=VALUE Message Headers
-F HEADERNAME --fnheader=HEADERNAME Put filename into this header
-S SUFFIX --suffix=SUFFIX Allowed file suffixes in hotfolder mode
-m --magic Toggle setting content-type and -encoding from file contents (default: False)
-e --persistent Set persistent delivery
-E --nonpersistent Set nonpersistent delivery
-o SERVER --server=SERVER AMQP Server (default: localhost)
-y VHOST --vhost=VHOST AMQP Virtual Host (default: /)
-x EXCHANGE --exchange=EXCHANGE AMQP Exchange (default: default)
-Q TEMPQNAME --qname=TEMPQNAME Name for temporary exclusive Queue
-p PORT --port=PORT Server Port Number (default: 5672)
-T --tls Toggle TLS (default: False)
-q QUEUENAME --queue=QUEUENAME Ignore Exchange and bind to existing Queue
-c CERTFILE --cert=CERTFILE TLS Client Certificate File
-k KEYFILE --key=KEYFILE TLS Client Private Key File
-U USERNAME --user=USERNAME Username for Auth
-P PASSWORD --pass=PASSWORD Password for Auth
-s INT --heartbeats=INT heartbeat interval (0=disable, default: set by server)
-n NAME --name=NAME connection name, will be shown in RabbitMQ web interface
If INPUTFILE is a file, the file is sent as a message and the program
exits. If INPUTFILE is a directory, the directory is watched via inotify
and every file, which is written and closed or moved in gets sent,
optionally only files which match one or several SUFFIXes. Optionally
the file name is written into a message header named HEADERNAME.
Optionally Content-Type and Content-Encoding headers are set via magic
retrieved from file contents.
Line-by-line mode sends one message per INPUTFILE line.
examples
Send a message containing a file and put the filename into a fileName
message header:
agitprop -x amq.topic -r test -F fileName -f agitprop.hs