Rabbit MQ Ctl - connection to channel mapping - rabbitmq

I need to get the mapping of queues to the ip of the consumers using rabbit mq ctl.
In the UI, i can see this in the consumers tag which gives me the IP and the port.
Using rabbit mq ctl
list_queues -> gives me the queue and channel name
rabbitmqctl list_queues
q1 <rabbit#sg-rabbitmq-0.1.32026.83>
list_consumers -> gives me the list of consumers for queues with the channel ids
rabbitmqctl list_consumers
q1 <rabbit#sg-rabbitmq-0.1.23140.1150> amq.ctag-efPo6z_2JPGTP_Rt02yjdA true 1 []
list_channels -> gives me the list of channels
rabbitmqctl list_channels pid connection number user vhost transactional
<rabbit#sg-rabbitmq-0.1.23140.1150> <rabbit#sg-rabbitmq-0.1.31144.1148> 6 admin / false
How do i get the connection and ip for which this channel is created ?

Figured it out, need to pass the connection parameters in list_channels
rabbitmqctl list_channels pid connection name number
<rabbit#sg-rabbitmq-0.1.23140.1150> <rabbit#sg-rabbitmq-0.1.31144.1148> 52.187.117.61:1232 -> 10.3.110.215:5672 (6) 6
Using the connection to grep against the connections gives the ip details
rabbitmqctl list_connections pid name | grep "rabbit#sg-rabbitmq-0.1.31144.1148"
<rabbit#sg-rabbitmq-0.1.31144.1148> 1.2.3.4:1232 -> 10.10.10.215:5672
Where rabbit#sg-rabbitmq-0.1.31144.1148 is the connection id.

Related

RabbitMQ channel has no consumer

I am trying to send a message to RabbitMQ via MQTT, however when the connection is established, the channel shows that is has ... no consumers .... To my understanding, upon connecting via MQTT to RabbitMQ, the topic will default to the amq.topic, and a new queue will be created for these connections.
Oddly enough, this does happen when I connect using Mosquitto, however, other MQTT clients do not get their own queue.
So, as an example, connecting like so: mosquitto_sub -h rabbit-01.<hostname.com> -p 1883 -u <v_host>:<username> -P <pass> -t "#"
produces:
HOWEVER!
my connection from the other server pub/sub mqtt integration thing results in no new queue displaying. Here are the settings for that:
Any help would be greatly apprecieated!
Thanks!

Get the latest message in the queue

I want to fetch the last / latest message added in the queue, is there a specific option available in the rabbitmqadmin utility.
The following command is giving the first message in the queue,
./rabbitmqadmin get queue='log' -H localhost -P 15672 -u <username> -p <password> --vhost=logging count=1
Are you looking to consume or view the messages? I use this tool plumber to view the latest incoming messages without removing them from the queue. If you are looking to consume just the latest message you may have to write a script.
To read the latest inbound message and exit:
plumber read messages rabbitmq --address amqp://user#pass:127.0.0.1:5672 --exchange events --routing-key \#
To watch all messages as they come in:
plumber read messages RabbitMQ --address amqp://user#pass:127.0.0.1:5672 --exchange events --routing-key \# --follow
If you use plumber your queue must be set up on its own exchange you can not use the RabbitMQ default exchange see.

rabbitmq - consumer without channel

There is clustered rabbitmq.
There is one connected consumer to it.
root#serwer1:~# rabbitmqctl list_consumers -p vhost1
Listing consumers ...
queue1.dlq <rabbit#serwer1.3.9529.109> amq.ctag-C5lFDLY7LZjnDdi1hjbAIA true 1000 []
...done.
There is connected with it channel:
root#serwer1:~# rabbitmqctl list_channels vhost pid state connection |grep rabbit#serwer1.3.9529.109
vhost1 <rabbit#serwer1.3.9529.109> running <rabbit#serwer1.3.9537.109>
But - there is no connected connection for it:
root#serwer1:~# rabbitmqctl list_connections vhost pid state |grep rabbit#serwer1.3.9529.109
root#serwer1:~#
How such situation is possible? How to fix it?
(rabbitmq 3.3.5 from debian jessie)

want to purge queue in remote machine rabbitmq

I am having rabbitmq up and running in another machine with ip address 10.8.11.12 on port 15672 and in that i am having a queue named "hello". I want to purge hello queue from my machine using CLI (command line interface)
I have tried following to purge queue in localhost
rabbitmqctl purge_queue
it is working fine
and i am trying the same like this
rabbitmqctl purge_queue -p 10.8.11.12 hello
here i am considering 10.8.11.12 as vhost. is it correct?
what actually vhost means in rabbitmq?
Even a simple link will help.
you have to use -n parameter as:
rabbitmqctl -n rabbit#your_other_machine purge_queue hello
here is an example:
./rabbitmqctl -n rabbit#srv-rabbit-cent01 purge_queue my_queue_1
where rabbit#srv-rabbit-cent01 is the rabbitmq node name. ( srv-rabbit-cent01 is the hostname )
about the vhost please read here: https://www.rabbitmq.com/uri-spec.html
2.4. Vhost
The vhost component is used as the basis for the virtual-host field of
the connection.open AMQP 0-9-1 method. Any percent-encoded octets in
the vhost should be decoded before the it is passed to the server.

Rabbitmq permissions

I'm working with rabbitmq permissions with python. The application has multiple clients and one service provider. I want to limit clients to specific queues while service provider should be capable to read all queues and not write to any. I try to set permissions as follow:
For service provider account I have set the following
rabbitmqctl set_permissions -p vhost service_provider ".*-client-queues" "" ".*-client-queues"
For clients I did
rabbitmqctl set_permissions -p vhost client1 "client1-client-queues" "client1-client-queues" ""
And the message is never delivered to service provider. However, if I set
rabbitmqctl set_permissions -p vhost client1 ".*" ".*" ".*"
it works. But I need to limit the clients to specific queues.
Does anyone of you try to achieve such thing? Any hints will be appreciated. Thanks.
service_provider and client1 must be the users that the respective components use instead of the default (guest) to connect to the RabbitMQ broker.
You need to create the users and set their passwords with rabbitmqctl add_user ..., then let the respective components use them.
Also note that the exchanges that you use to publish messages to, must match the write permission that you specify. See here for details.
I suggest you add the permissions one-by-one, so you see rapidly what you are doing wrong.
What I'm missing is the exchange name while I set the permissions. I've solved my problem with the following permissions: (I'm using default exchange)
For clients:
rabbitmqctl set_permissions -p vhost client1 "client1-client-queues|amq\.default" "client1-client-queues|amq\.default" "amq\.default"
For service provider:
set_permissions -p vhost service_provider ".*-client-queues|amq\.default" "amq\.default" ".*-client-queues|amq\.default"