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
Related
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.
I came across an interesting subject when reading the book "RabbitMQ in Action" by Manning. Apparently it's possible to set up consumers to be able to receive all RabbitMQ logging in real time in the consumer.
I read that RabbitMQ publishes logging to an exchange of type topic called amq.rabbitmq.log. Consumers can listen to specific severity levels, for example it can be filtered by setting the routing key to error, warning or info.
My question is; I installed a default RabbitMQ server on my PC, but I couldn't find any exchange called amq.rabbitmq.log. Only one which could be related is amq.rabbitmq.trace, but this one is used for events (events like queue.deleted, queue.created, ...), in other words that one is not what I'm looking for.
Can anyone bring clarification to my questions? Why is the amq.rabbitmq.log exchange not available on a clean RabbitMQ server installation?
citation:
Perhaps when you were listing exchanges using rabbitmqctl you spotted
an exchange called amq.rabbitmq.log whose type is topic. RabbitMQ will
publish its logs to that exchange using the severity level as a
routing key - you'll get error, warning and info. Based on what you
learned from the previous chapters you can create a consumer to
listen to those logs and react accordingly.
You have to enable it. Create the /etc/rabbitmq/rabbitmq.conf file and ensure that this line is present in it:
log.exchange = true
I just grepped the source for the rabbitmq.com website and don't see that setting documented anywhere. If you'd like, file a new issue in that repository and I'll fix it, or open your own PR to do so.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
It is a bit late, but hope it help someone. So far it works for me. The exchange "amq.rabbitmq.log" will be created automatically by the rabbitmq broker itself. The RabbitMQ broker version that I am using is: 3.8.1
add
log.exchange = true
into your rabbitmq.conf file and restart your rabbitmq service.
You will need to restart your rabbitmq service everytime you had updated the rabbitmq.conf file.
open cmd and enter the following in windows:
rabbitmq-service stop
rabbitmq-service install
rabbitmq-service start
rabbitmqctl start_app
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.
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)
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