qc

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2018 License: MIT Imports: 6 Imported by: 0

README

qc

License Build Status Go Report

"queue cat"

A command line utility for publishing and subscribing to AMQP 0.9.1 message queues, like RabbitMQ.

Note: This application is in alpha status until a 1.0.0 release.

Installation

Head over to releases and download the appropriate binary for your system. Put the binary in a convenient place, such as /usr/local/bin/qc.

Usage

By default, qc connects to a message queue broker at amqp://guest:guest@localhost:5672/. Pass -u with an alternate URL, or set the QC_BROKER_URL environment variable to change the broker to which qc connects.

Supply an exchange name with the -e option. Supply one or more routing keys with the -r option. Pass -t with value direct (default), fanout, headers, or topic to control the exchange type.

qc can be executed in producer or consumer mode.

Consumer Mode

Consume messages by passing the -c option, an exchange name (-e), and some routing keys (-r) on which to bind.

qc -c -e logs -r info -r error

This declares an exchange named logs of the default type direct. It creates an exclusive queue having a generated name, and binds that queue to the exchange for each routing key supplied (info, and error), or once with an empty routing key if none is supplied. Lastly, it consumes messages from the queue, writing them to stdout, until the process is killed.

Producer Mode

Producer mode is the default, active when -c is omitted.

Publish messages by passing input to qc through stdin, supplying the exchange name (-e) and a routing key (-r).

echo "oh no!" | qc -e logs -r error

This declares an exchange named logs of the default type direct, and publishes the given message to it.

Examples

Direct Exchange

Create separate consumers that are interested only in specific log levels on exchange logs. As direct is the default exchange type, we can omit the -t option.

# error handler
$ qc -c -e logs -r error
# info handler
$ qc -c -e logs -r info

Now log some messages.

# logger A
$ echo "your bike was stolen!" | qc -e logs -r error
$ echo "your mother-in-law was kidnapped" | qc -e logs -r info

Consumers receive only the relevant messages.

# error handler
$ qc -c -e logs -r error
your bike was stolen!
# info handler
$ qc -c -e logs -r info
your mother-in-law was kidnapped
Pub-Sub / Fan-Out

Create some consumers to receive log messages on exchange logs. Routing keys are not needed for fanout.

# consumer A
$ qc -c -t fanout -e logs
# consumer B
$ qc -c -t fanout -e logs

Publish log messages.

# producer A
$ echo "Houston, there's cake" | qc -t fanout -e logs

Both consumers receive the message.

# consumer A
$ qc -c -t fanout -e logs
Houston, there's cake
# consumer B
$ qc -c -t fanout -e logs
Houston, there's cake
Topics

Create consumers that are interested in particular topics.

# any-colour rabbit consumer
qc -c -t topic -e animals -r '*.rabbit'
# blue animal consumer
qc -c -t topic -e animals -r 'blue.*'

Publish some animal names.

# producer A
echo "roger" | qc -t topic -e animals -r white.rabbit
echo "dick"  | qc -t topic -e animals -r blue.whale
echo "ted"   | qc -t topic -e animals -r blue.rabbit
echo "jerry" | qc -t topic -e animals -r red.eagle

Consumers receive only the relevant messages.

# any-colour rabbit consumer
qc -c -t topic -e animals -r '*.rabbit'
roger
ted
# blue animal consumer
qc -c -t topic -e animals -r 'blue.*'
dick
ted

License

MIT © Troy Kinsella

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL