A netcat-like tool for sending things through RabbitMQ.
npm install -g rmqcatrmqcat --help
rmqcat has two modes of use, one-way and two-way ("duplex"). Duplex
corresponds more or less to how
netcat works, that is, it
establishes a socket-like connection with a server ('listener') on one
side and a client on the other, which can speak back and forth.
One-way (simplex) either relays stdin to a RabbitMQ queue, or from a RabbitMQ queue to stdout. Sending to a queue doesn't wait for a receiver; receiving from a queue waits for data in the queue.
Common to both modes
--url can be used to address a specific RabbitMQ server,
and to provide connection parameters -- see the amqplib
documentation. By default a RabbitMQ server on
localhost is assumed, so you will probably want to supply
-D will make rmqcat output a bit of debug information to
--help, if present at all, will make rmqcat output a
usage message to stderr then exit.
# Start a listener that will put whatever it gets in a filermqcat -l > recv.txt# Send a file to the listenerrmqcat < send.txt
rmqcat used this way will keep a connection open until it gets
end-of-file, so you can use it to "chat" back and forth, similar to
A client (i.e., without
-l) will buffer input until its connection
is accepted by a listener.
-k in combination with
-l will keep the listener
accepting successive connections. Otherwise it will exit once the
first connection closes.
--exec causes rmqcat to spawn a child process
using the argument following and redirect stdin and stdout of that
process to the queue. For example,
rmqcat -l --exec "grep -n foo"
If the option
-k is used in combination with
-e, the child process
will be run for each connection made. In a client, the process is run
once the connection is accepted.
--service has a role similar to a TCP port number. It
names a queue to be used by clients and listeners to establish
connections. The default is arbitrarily
# Send a file to a queuermqcat --send bobbins < bobbins.iso# Save the file in a queue and output the SHA1 sumrmqcat --recv bobbins | tee bobbins.iso | shasum
The string following either
--recv names a queue that
will hold the data in transit. More than one file of data can be
present in the queue;
rmqcat --recv <queue> will read a single file
before exiting, or wait if there is no data yet.