Giter Club home page Giter Club logo

rmqctl's Introduction

travis go report go doc license release


rmqctl is the swiss-army knife tool for rabbitmq with kubectl like commands.


Binary Release:

binary release v1.0.15
  • 'rmqctl publish' now publishes input from STDIN.
  • 'rmqctl publish' -e flag now takes executable with arguments.

e.g -e "/usr/bin/ls -al"

binary release v1.0.14
  • 'rmqctl publish' adds new flag '-e' for user provided executable,

    which generates messages to 'stdout' where rmqctl consumes and publishes to the queue.

binary release v1.0.12
  • fix issues for rabbit-hole.DeleteBinding uses BindingInfo.PropertiesKey as routing key

instead of BindingInfo.RoutingKey

binary release v1.0.11
  • Logging bug fix
binary release v1.0.10
  • Purge queue / purge queue with prompt [y/n]
  • Consume queue with numbers, e.g only consumes 10 messages
binary release v1.0.9
  • honors -a, -d in create queue/exchange
binary release v1.0.8
  • Now supports TLS connection for AMQP and HTTPS
  • New 'tls' entry in rmqctl.conf
  • New flag '-T' indicates using TLS connection.
  • Bug fix.
binary release v1.0.7
  • Now supports burst message publish mode.

    Alone with daemon mode, rmqctl is used as a stress test tool for rabbitmq.

    e.g.

    $ rmqctl publish exchange_name routing_key "MESSAGE" -b 1000000

    Publish with other payload

    $ rmqctl publish exchange_name routing_key "$(cat payload.json)" -b 1000000

  • Now supports publish mode: Transient, Persistent

  • Change default config file name to rmqctl.conf

  • Change load config file name flag to '-c'

  • Formalize debug log message.

binary release v1.0.3
  • Publish/Consume use amqp protocol for performance. Other actions using rabbitmq REST API calls.
  • Now supports bash/rawjson output format.
binary release v1.0.0
  • init. release

rmqctl loads rmqctl.conf (yaml) under working directory if there is one. Command arguments have higher precedence if provided.

username: guest
password: guest
port: 5672
apiport: 15672
host: localhost
tls: true
vhost: "/"
Loads rmqctl.conf from other location
$ rmqctl -c path/to/rmqctl.conf COMMANDS

Supports

AMQP Protocol

rmqctl uses amqp protocol library for publish/consume message for speed.

rmqctl supports burst publish/daemon consume, act as a perfect tool for stress test

and debugging the application.

TLS support

Place client certificate and private key pair with read only permission (0400)

under $HOME/.ssh/ name as follows:

~/.ssh/rmq_cert.pem
~/.ssh/rmq_key.pem

If rabbitmq server using self-signed certificate,

remember to register self-signed CA into client's host system.

Setting up rabbitmq server TLS support for both

AMQP and API Service config file can refere to example:

rabbitmq_tls.config

Create

  • queue, queue in HA mode(with single command)
  • exchange
  • queue/exchange binding
  • user
  • vhost
  • --help for more features

List

  • queue
  • exchange
  • queue/exchange binding
  • user
  • vhost
  • node
  • policy
  • --help for more features

Delete

  • queue
  • exchange
  • queue/exchange binding
  • user
  • vhost
  • policy
  • --help for more features

Update

  • vhost
  • user
  • --help for more features

Publish

  • Publish with routing key
  • Publish messages generated from user provided executable
  • Burst publishing (testing throughput)
  • Supports transient|persistent modes
  • --help for more features

Consume

  • Consume supports ack|nack|reject|auto-ack acknowledge modes.
  • Run as daemon, consume on-demand.
  • Consume number of messages with flag -c NUMBER
  • --help for more features

Purge

  • Purge queue with prompt
  • --help for more features

Usage

Create queue

// TEST_QUEUE_1 created as durable
$ rmqctl create queue TEST_QUEUE_1 -d
done

// TEST_QUEUE_2 created as durable and autodelete
$ rmqctl -d create queue TEST_QUEUE_2 -d -a
done

Create queue in HA mode

rmqctl is able to create queue in HA mode.

Three modes supported: all(default),exactly,nodes

Following command creates TEST_QUEUE_3 queue in HA mode,

which by default it has queue slaves in all other rabbitmq nodes (default: 'all' mode)

rmqctl automatically creates queue's HA policy with name: QueueName_HA

$ rmqctl create queue TEST_QUEUE_3 --HA
done

List all queues

$ rmqctl list queue
|Name         |Vhost |Durable |AutoDelete |MasterNode |Status |Consumers |Policy          |Messages
|TEST_QUEUE_1 |/     |true    |false      |rabbit@r1  |       |0         |                |0
|TEST_QUEUE_2 |/     |true    |true       |rabbit@r1  |       |0         |                |0
|TEST_QUEUE_3 |/     |true    |true       |rabbit@r1  |       |0         |TEST_QUEUE_3_HA |0

List Policy

$ rmqctl list policy
 Name            |Vhost |Pattern      |Priority |ApplyTo |Definition
|TEST_QUEUE_3_HA |/     |TEST_QUEUE_3 |0        |queues  |map[ha-mode:all ha-sync-mode:automatic]

List particular queue in json

$ rmqctl list queue TEST_QUEUE_1 -o json
[
  {
    "name": "TEST_QUEUE_1",
    "vhost": "/",
    "durable": true,
    "auto_delete": false,
    "arguments": {},
    "node": "rabbit@r1",
    "status": "",
    "memory": 10576,
    ...
    }
 ]

Create exchange

$ rmqctl create exchange TEST_EXCHANGE_1 -d -t fanout
done

List all exchanges

$ rmqctl list exchange
 |Name               |Vhost |Type    |Durable |AutoDelete
 |                   |/     |direct  |true    |false
 |TEST_EXCHANGE_1    |/     |fanout  |true    |false
 |amq.direct         |/     |direct  |true    |false
 |amq.fanout         |/     |fanout  |true    |false
 |amq.headers        |/     |headers |true    |false
 |amq.match          |/     |headers |true    |false
 |amq.rabbitmq.trace |/     |topic   |true    |false
 |amq.topic          |/     |topic   |true    |false

List particular exchange in json

$ rmqctl list exchange TEST_EXCHANGE_1 -o json
{
  "name": "TEST_EXCHANGE_1",
  "vhost": "/",
  "type": "fanout",
  "durable": true,
  "auto_delete": false,
  "internal": false,
  "arguments": {},
  "incoming": [],
  "outgoing": []
}

Create queue/exchange binding

rmqctl is able to create exchange bindings as well.

$ rmqctl create bind TEST_EXCHANGE_1 TEST_QUEUE_1 ROUTING_KEY
done
$ rmqctl create bind TEST_EXCHANGE_1 TEST_QUEUE_2 ROUTING_KEY
done

Creates exchange binding
$ rmqctl create bind TEST_EXCHANGE_1 TEST_EXCHANGE_2 ROUTING_KEY -t exchange
done

List queue/exchange binding

$ rmqctl list bind
|Source          |Destination     |Vhost |Key          |DestinationType
|                |TEST_QUEUE_1    |/     |TEST_QUEUE_1 |queue
|                |TEST_QUEUE_2    |/     |TEST_QUEUE_2 |queue
|TEST_EXCHANGE_1 |TEST_QUEUE_1    |/     |RUN          |queue
|TEST_EXCHANGE_1 |TEST_EXCHANGE_2 |/     |RUN          |exchange

Publish message

Publish to a fanout exchange, observing queues bounded to the

exchange TEST_EXCHANGE_1 received the message.

$ rmqctl publish TEST_EXCHANGE_1 RUN "This is a test message"
done

$ rmqctl list queue
|Name         |Vhost |Durable |AutoDelete |MasterNode |Status |Consumers |Policy          |Messages
|TEST_QUEUE_1 |/     |true    |false      |rabbit@r1  |       |0         |                |1
|TEST_QUEUE_2 |/     |true    |true       |rabbit@r1  |       |0         |                |1
|TEST_QUEUE_3 |/     |true    |true       |rabbit@r1  |       |0         |TEST_QUEUE_3_HA |0

Publish message in burst mode

Publish to a fanout exchange in burst mode,

observing queues bounded to the exchange TEST_EXCHANGE_1 received the message.

$ rmqctl publish TEST_EXCHANGE_1 RUN "This is a test message" -b 424242
done

$ rmqctl list queue
|Name         |Vhost |Durable |AutoDelete |MasterNode |Status |Consumers |Policy          |Messages
|TEST_QUEUE_1 |/     |true    |false      |rabbit@r1  |       |0         |                |424243
|TEST_QUEUE_2 |/     |true    |true       |rabbit@r1  |       |0         |                |424243
|TEST_QUEUE_3 |/     |true    |true       |rabbit@r1  |       |0         |TEST_QUEUE_3_HA |0

Publish message from user provided executable

Publish messages generated from user provided executable to the queue.

$ rmqctl publish TEST_EXCHANGE_1 RUN -e "/usr/bin/ls -al"
done

$ rmqctl consume TEST_QUEUE_1
|Message
 drwxr-xr-x 1 vs   users    1566 Mar 16 13:07 Desktop
 drwxr-xr-x 1 vs   users       0 Feb 11 21:25 Documents
 drwxr-xr-x 1 vs   users     616 Mar 17 15:34 Downloads
 drwxr-xr-x 1 vs   users     322 Feb 13 08:40 .fzf

Publish message from STDIN

Publish messages read from STDIN.

$ rmqctl publish TEST_EXCHANGE_1 RUN
hello, rabbitmq!
greetings, rabbitmq!
done

$ rmqctl consume TEST_QUEUE_1
|Message
 hello, rabbitmq!
 greetings, rabbitmq!

$ rmqctl publish TEST_EXCHANGE_1 RUN  <<< "hi, there!"
done

$ rmqctl consume TEST_QUEUE_1
|Message
 hi, there!

equivalent to $ rmqctl publish TEST_EXCHANGE_1 RUN -e "/usr/bin/ls -al"
$ ls -al | rmqctl publish TEST_EXCHANGE_1 RUN
done

$ rmqctl consume TEST_QUEUE_1
|Message
 drwxr-xr-x 1 vs   users    1566 Mar 16 13:07 Desktop
 drwxr-xr-x 1 vs   users       0 Feb 11 21:25 Documents
 drwxr-xr-x 1 vs   users     616 Mar 17 15:34 Downloads
 drwxr-xr-x 1 vs   users     322 Feb 13 08:40 .fzf

Consume message

Consume 3 messages.

$ rmqctl consume TEST_QUEUE_1 -c 3
|Message
This is a test message
This is a test message
This is a test message

Consume message in daemon mode

$ rmqctl consume TEST_QUEUE_2 -d
|Message
This is a test message
This is a test message
...

Purge queue

Purge queue without prompt.

$ rmqctl purge TEST_QUEUE_1 -f
done

Other features including list/update user/vhost/node information, vhost tracing, etc.

--help for more details.

$ rmqctl --help

Contact

Bug, feature requests, welcome to shoot me an email at:

vsdmars<<at>>gmail.com

rmqctl's People

Contributors

buddhavs avatar vsdmars avatar

Stargazers

Sayaka avatar  avatar Rajan Ponnappan avatar Leon Hartley avatar Doru Carastan avatar Myles avatar  avatar Philipp Meier avatar Valentin Fritz avatar Jeremy W. Sherman avatar liujieking avatar Tyler Koske avatar Łukasz Korecki avatar  avatar Simon Escobar Benitez avatar Dave Cottlehuber avatar bradley avatar Martin Schröder avatar William Delanoue avatar R. Mathieu Landvreugd avatar  avatar  avatar Mordy Ovits avatar  avatar Kristinn Örn Sigurðsson avatar Gudjon avatar  avatar Ramon Pires da Silva avatar Gergan Penkov avatar verbalsaint avatar Andri Óskarsson avatar

Watchers

Konstantin Krehl avatar

rmqctl's Issues

[READ FIRST] Thanks :-)

While reporting issues, please fire the command with -d , which will print out the debug log, thus
easier for dev to look into the issues,
i.e
$ rmqctl -d COMMANDs

Thanks :-)

SIGSEGV on attempt to create queue

$ rmqctl create queue -d my_durable_queue
done
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x13a34f9]

goroutine 1 [running]:
github.com/vsdmars/rmqctl/pkg.handleHTTPResponse(0x0, 0x14a3937, 0x6, 0x14a365a, 0x5, 0x1, 0x0)
	pkg/http.go:20 +0x1e9
github.com/vsdmars/rmqctl/pkg.createQueue(0xc0002bea00, 0xc0002f40b0, 0x0, 0x0)
	pkg/rmqapi_action.go:130 +0xd4
github.com/vsdmars/rmqctl/pkg.createQueueJob(0xc0002de420, 0x18, 0xc000200b60)
	pkg/rmqapi_job.go:19 +0xa1
gopkg.in/urfave/cli%2ev1.HandleAction(0x142dc40, 0x14be9b8, 0xc0002de420, 0xc0002de420, 0xc000200ef8)
	external/in_gopkg_urfave_cli_v1/app.go:488 +0x101
gopkg.in/urfave/cli%2ev1.Command.Run(0x14a365a, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14b7d2c, 0x3f, 0x14a9039, ...)
	external/in_gopkg_urfave_cli_v1/command.go:210 +0x9a2
gopkg.in/urfave/cli%2ev1.(*App).RunAsSubcommand(0xc0002b8340, 0xc0002de000, 0x0, 0x0)
	external/in_gopkg_urfave_cli_v1/app.go:379 +0x7ef
gopkg.in/urfave/cli%2ev1.Command.startApp(0x14a3937, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14a6724, 0xf, 0x14b8c34, ...)
	external/in_gopkg_urfave_cli_v1/command.go:298 +0x808
gopkg.in/urfave/cli%2ev1.Command.Run(0x14a3937, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14a6724, 0xf, 0x14b8c34, ...)
	external/in_gopkg_urfave_cli_v1/command.go:98 +0x1250
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc0002b8000, 0xc00001e050, 0x5, 0x5, 0x0, 0x0)
	external/in_gopkg_urfave_cli_v1/app.go:255 +0x687
github.com/vsdmars/rmqctl/pkg.Cmd(0x0, 0x0)
	pkg/cmd.go:694 +0x33e
github.com/vsdmars/rmqctl/cmd.Cmd(0x13a3720, 0xc000201f68)
	cmd/cmd.go:9 +0x22
main.main()
	main.go:10 +0x26

seems like tool tries to create a queue using HTTP endpoint, which is not available.

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.