Over a million developers have joined DZone.

AMQPcat, a Netcat-like Tool for Messaging Fun

DZone's Guide to

AMQPcat, a Netcat-like Tool for Messaging Fun

· Integration Zone
Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

If you have read @ripienaar's excellent series of articles on common messaging patterns you probably noticed a handy CLI tool for working with STOMP queues called stompcat. I looked around for something similar for AMQP brokers but couldn't find anything quite the same. There is amqp-utils but I had some issues with these and the tools didn't work quite like I was hoping. So I wrote amqpcat with the idea of providing a similar tool to stompcat.

Available on github and rubygems.org: https://github.com/joemiller/amqpcat

Installation is easy:

sudo gem install amqpcat --no-rdoc --no-ri

1:1 Messaging demonstration

Publish a message:

$ echo "hello there" | amqpcat amqp://guest:guest@rabbitmq -t direct -n test.direct --publisher

Receive the message:

$ amqpcat amqp://guest:guest@rabbitmq -t direct -n test.direct --consumer
hello there

Pretty simple. There are various other options, run with -h to see them all. You can easily load-balance amongst multiple consumers by starting multiple consumers with the same url and options. See the test_direct.sh example for a demo of this.

1:N / PubSub Messaging

Start 2 (or more) consumers:

$ amqpcat amqp://rabbitmq -t fanout -n test.fanout -s "Consumer-1: " --consumer &
$ amqpcat amqp://rabbitmq -t fanout -n test.fanout -s "Consumer-2: " --consumer &

Publish a message:

$ echo "hello there" | amqpcat amqp://guest:guest@rabbitmq -t fanout -n test.fanout --publisher

You should see both consumers receive the message, ie:

Consumer-1: hello there
Consumer-2: hello there

See test_fanout.sh for a similar example.

SSL support

SSL support (server verification, and client certs) has been written into the tool but I have not been able to test it to a working state yet.

Source:  http://joemiller.me/2012/02/08/amqpcat-a-netcat-like-tool-for-messaging-fun/

The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.


Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}