GithubHelp home page GithubHelp logo

amqpcat's Introduction

amqpcat

netcat for AMQP. CLI tool to publish to and consume from AMQP servers.

Installation

Using snap:

snap install amqpcat

Using Homebrew in OS X:

brew install cloudamqp/cloudamqp/amqpcat

Using Docker/Podman:

docker run -it cloudamqp/amqpcat

From source:

brew install crystal # os x
snap install crystal # linux/ubuntu

git clone https://github.com/cloudamqp/amqpcat.git
cd amqpcat
shards build --release --production

There are more Crystal installation alternatives.

Usage

Usage: amqpcat [arguments]
    -P, --producer                   Producer mode, reading from STDIN, each line is a new message
    -C, --consumer                   Consume mode, message bodies are written to STDOUT
    -u URI, --uri=URI                URI to AMQP server
    -e EXCHANGE, --exchange=EXCHANGE Exchange
    -r ROUTINGKEY, --routing-key=KEY Routing key when publishing
    -q QUEUE, --queue=QUEUE          Queue to consume from
    -f FORMAT, --format=FORMAT       Format string (default "%s\n")
				     %e: Exchange name
				     %r: Routing key
				     %s: Body, as string
				     \n: Newline
				     \t: Tab
    -v, --version                    Display version
    -h, --help                       Show this help message

Examples

Send messages to a queue named test:

echo Hello World | amqpcat --producer --uri=$CLOUDAMQP_URL --queue test

Consume from the queue named test:

amqpcat --consumer --uri=$CLOUDAMQP_URL --queue test

With a temporary queue, consume messages sent to the exchange amq.topic with the routing key 'hello.world':

amqpcat --consumer --uri=$CLOUDAMQP_URL --exchange amq.topic --routing-key hello.world

Consume from the queue named test, format the output as CSV and pipe to file:

amqpcat --consumer --uri=$CLOUDAMQP_URL --queue test --format "%e,%r,"%s"\n | tee messages.csv

Publish messages from syslog to the exchange 'syslog' topic with the hostname as routing key

tail -f /var/log/syslog | amqpcat --producer --uri=$CLOUDAMQP_URL --exchange syslog --routing-key $HOSTNAME

Consume, parse and extract data from json messages:

amqpcat --consumer --queue json | jq .property

Development

amqpcat is built with Crystal

Contributing

  1. Fork it (https://github.com/cloudamqp/amqpcat/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

amqpcat's People

Contributors

carlhoerberg avatar dentarg avatar johanrhodin avatar kickster97 avatar snichme avatar walro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amqpcat's Issues

No available formula

$ brew update
Already up-to-date.

$ brew install cloudamqp/amqpcat
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "cloudamqp/amqpcat".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.

Output each message into a new file

Hi,
I'm using this command from the examples:
amqpcat --consumer --uri=$CLOUDAMQP_URL --queue test --format "%e,%r,"%s"\n | tee messages.csv

Can I somehow create a new file for each incoming message (instead of appending to a single file)?
Eg. | tee logfile_$(date '+%Y-%m-%d_%T_%N').json (this obviously doesn't work)

Auto reconnect producer after connection errors

I'm running a producer.
After about 10 to 20 minutes I always receive an EOF from server error.
Can we somehow get the producer to automatically reconnect?

amqpcat -P -u amqp://user:pass@host:port/vhost -r new.contact -e synchronizer
test1
test2
ERROR - amqp.client.connection: connection closed unexpectedly: End of file reached
End of file reached (IO::EOFError)
  from /usr/share/crystal/src/gc/boehm.cr:129:5 in 'read_loop'
  from /usr/share/crystal/src/fiber.cr:146:11 in 'run'
  from ???
test3
^C
amqpcat -P -u amqp://user:pass@host:port/vhost -r new.contact -e synchronizer
test4
test5

I'm also running a consumer.
Here I also get the EOF from server error, but I still get new messages after that so it's not an issue.

amqpcat -C -u amqp://user:pass@host:port/vhost -r new.contact -e synchronizer
test1
test2
ERROR - amqp.client.connection: connection closed unexpectedly: End of file reached
End of file reached (IO::EOFError)
  from /usr/share/crystal/src/gc/boehm.cr:129:5 in 'read_loop'
  from /usr/share/crystal/src/fiber.cr:146:11 in 'run'
  from ???
test4
test5

As you can see test3 is missing in the consumer output.

Bildschirmfoto vom 2022-11-29 10-24-18

How to Auth?

Getting a 403 access refused saying that "Login was refused using authentication mechanism PLAIN."

How can I utilize a basic User/Password authentication? Easy to use ENV variables?

feature: rpc api

I'm a long time user of rabbiteer but it doesn't support TLS.
It would be great if amqpcat could lift 2 features that are really useful for publishing:

$ rabbiteer -U $AMQP_URI publish \
  --rpc --rpctimeout 3000 \
  --routing-key some.key \
  --content-type application/json \
  -file /tmp/stuff.json

rpc api

Using a routing key, and an automatically created direct reply-to queue, allows
a nice RPC interface, a la https://www.rabbitmq.com/docs/direct-reply-to &
https://www.rabbitmq.com/tutorials/tutorial-six-go

feature: publishing header support

I'm a long time user of rabbiteer but it doesn't support TLS.
It would be great if amqpcat could lift 2 features that are really useful for publishing:

$ rabbiteer -U $AMQP_URI publish \
  --rpc --rpctimeout 3000 \
  --routing-key some.key \
  --content-type application/json \
  -file /tmp/stuff.json

headers

  • adding a content-type header (or possibly other arbitrary headers)
  • auto-detcting content-type from file extension is nice but not essential

No ARM build availble in snap

error: snap "amqpcat" is not available on stable for this architecture (arm64) but exists on other
       architectures (amd64).

Set amqpcat as client name

Currently it is just passing on the underlying amqp-client.cr

platform | Crystal
product  | amqp-client.cr
version | 0.5.16

Wrong operation on default exchange

After "support for decalring[sic] exchanges, with exchange type" the hello world example is broken:

403 - ACCESS_REFUSED - operation not permitted on the default exchange

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.