Rabbitmqctl usage to delete Queues - rabbitmq

How to
create/delete exchange,
create/delete Queues
bind/unbind queues
using rabbitmqctl.
Please suggest me.
I am using rabbitmq on windows.

With rabbitmqctlyou can't.
You can so that using Management Command Line Tool
The management plugin ships with a command line tool rabbitmqadmin
which can perform the same actions as the web-based UI, and which may
be more convenient for use when scripting. Note that rabbitmqadmin is
just a specialised HTTP client; if you are contemplating invoking
rabbitmqadmin from your own program you may want to consider using the
HTTP API directly.

Related

Scripting RabbitMQ bindings

I want to set up a bunch of rabbitMQ exchanges and queues together with their bindings trough a Octopus deploy step. We're using NServiceBus and we don't want to give the application too much permission hence it can't set up the stuff itself.
Previously we've had a powershell script for setting up virtual host and users and I've been looking at extending this so that we can create the queues, exchanges and bindings too. This script uses RabbitMQ REST API.
The queues and exchanges can be created without any hazzle but the bindings are another matter. I can't find any suitable documentation about setting this up over HTTP. I've read something that this is not the preferred way to do stuff but what options are available to me given octopus scripting?
The code I want to execute is something like this:
http://localhost:15672/api/bindings/TestHost/e/nsb.delay-level-00/q/nsb.delay-level-00
The exchange is named nsb.delay-level-00 and the queue has the same name. Both exists in the rabbitMQ virtual host.
Any ideas?
I found out that, in contrast to creating queues and exchanges, the method call has to be a POST in this scenario.
So, POST http://localhost:15672/api/bindings/TestHost/e/nsb.delay-level-00/q/nsb.delay-level-00 works fine.

Rabbitmqctl usage to do configuration

I am using RabbitMq on windows. I am trying to explore rabbitmqctl options.
i could see options to purge queue, create and delete shovels.
can you please tell me the rabbitmqctl usage to,
1. Create and delete exchange
2. Create and delete queues.
3. Bind and unbind queues.
i am trying to write scripts that can automate all the configurations based on input.
Look at rabbitmqadmin tool, it ships with RabbitMQ Management Plugin. It can declare/delete exchanges/queues/bindings.
Also look at this question and this post.
Just google "rabbitmqadmin your action"
Also you can use Management REST API

RabbitMQ Management Plugin vs. AMQP

I wish to programmatically manage exchanges, queues, bindings, and view resource usage of my rabbitmq server. I can do all these by making REST API calls made available by rabbitmq management plugin. However, is it possible to achieve all that using AMQP protocol instead of using the management plugin? In other words, will an AMQP client allow me to do everything that the management plugin does?
If there is no alternative, is there any performance concern if I enable and use the management plugin?
In theory someone could implement a way that all the info is delivered via an AMQP queue. But it would have to be so that no consumer should ACK any of the messages because then they would be gone from the queue and the publisher would have to figure this out and publish the same thing again. In other words, it shouldn't be done.Also it would be semantically (?) wrong, since AMQP by it's nature is designed with flowing/changing/dynamic data in mind, and all this data about resources, queues etc is static (and in some cases meta) info.
No performance concerns (in this context of course).
Additionally you can also use the command line tool if it's more comfortable
AMQP 0.9.1 does not have any way of discovery or listing of queues and exchanges. Management plugin, on the other hand, has APIs such as GET /api/exchanges and GET /api/queues. Due to this requirement, management plugin was my only solution.

How can I delete a RabbitMq exchange?

I can easily delete queues, like this:
rabbitmqadmin delete queue name='MyQ'
However, I cannot find a way to delete exchanges. What am I missing?
➜
./rabbitmqadmin delete exchange name='myexchange'
exchange deleted
you can also get the same functionality with the rabbitmq management web interface,
usually accessible via localhost:15672
(the rabbitmq management plugin need to be installed, usually the case)

RabbitMQ : how to create and restore backup

I'm new to RabbitMQ and i need some help.
how to do backup and restore to RabbitMQ, and what is the important data i need to save.
thanks!
If you have the management plugin installed you can back-up and restore the broker on the Overview page. At the bottom you will see Import/Export Definitions and you can use this to download a JSON representation of your broker.
This will restore Exchanges, Queues, Virtual Hosts, Policies and Users.
Hope that helps.
For those looking for the HTTP API endpoint, it is:
http://rabbit:15672/api/definitions
Another way to automate this is to use the command line tool rabbitmqadmin (http://rabbit:15672/cli/) add pass the export subcommand, e.g.
rabbitmqadmin export rabbit-backup.config