rabbitmq - consumer without channel - rabbitmq

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)

Related

Rabbit MQ Ctl - connection to channel mapping

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.

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 cluster join does not work

I have a rabbitmq cluster with 2 nodes. Node A and B. Node A is up and running. Everytime I run the following commadn on node A I get:
./rabbitmqctl cluster_status
Cluster status of node rabbit#A ...
[{nodes,[{disc,[rabbit#A,rabbit#B]}]},
{running_nodes,[rabbit#A]},
{partitions,[]}]
...done.
Interestingly node B is up and running. Everytime I have it join the other node (A) to get it clustered it states:
rabbitmqctl join_cluster rabbit#A
...done (already_member).
rabbitmqctl cluster_status
Cluster status of node rabbit#B ...
[{nodes,[{disc,[rabbit#B]}]}]
...done.
So somehow node A cannot see B. And on be the "already_member" does not seem to be reflected from the cluster_status command...
I can check the queues on both nodes and they are different. Node A has dozens of queues and node B none, therefore it is clear the cluster is not established. Both node A and B can ping each other and nothing gets reported in the rabbitmq's logs
Any idea how this is not working ?
In case of cluster I will suggest you to go for Load Balancer . Make sure you already set HA Policy for your cluster.
To set HA Policy
$ rabbitmqctl set_policy ha-all "" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
More here RabbitMQ Cluster
I was able to solve this same problem. Given NodeA is the parent and NodeB is trying to join the cluster.
Stop NodeB app rabbitmqctl stop_app
On NodeA forget cluster node rabbitmqctl forget_cluster_node rabbit#NodeB
Reset NodeB rabbitmqctl reset
Join NodeB to the cluster rabbitmqctl join_cluster rabbit#NodeA
Start NodeB rabbitmqctl start_app

How to use rabbitmqctl to connect to the rabbitmqserver in the docker container?

I've used docker to start my rabbitmqserver. How can I use rabbitmqctl to connect to the rabbitmqserver in the docker container?
Port 5672 has been exposed and map to the 5672 port of my host. But I still get the following error:
Status of node rabbit#m2 ...
Error: unable to connect to node rabbit#m2: nodedown
Assuming your container is called rabbitmq and is running:
docker exec rabbitmq rabbitmqctl start_app
rabbitmqctl uses Erlang Distributed Protocol (EDP) to communicate with RabbitMQ. Port 5672 provides AMQP protocol. You can investigate EDP port that your RabbitMQ instance uses:
$ netstat -uptan | grep beam
tcp 0 0 0.0.0.0:55950 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 31446/beam.smp
tcp 0 0 127.0.0.1:55096 127.0.0.1:4369 ESTABLISHED 31446/beam.smp
tcp6 0 0 :::5672 :::* LISTEN 31446/beam.smp
It means that RabbitMQ:
connected to EPMD (Erlang Port Mapper Daemon) on 127.0.0.1:4369 to make nodes able to see each other
waits for incoming EDP connection on port 55950
waits for AMQP connection on port 5672 and 55672
waits for incoming HTTP management connection on port 15672
To make rabbitmqctl able to connect to RabbitMQ you also have to forward port 55950 and allow RabbitMQ instance connect to 127.0.0.1:4369.
It is possible that RabbitMQ EDP port is dinamic, so to make it static you can try to use ERL_EPMD_PORT variable of Erlang environment variables or use inet_dist_listen_min and inet_dist_listen_max of Erlang Kernel configuration options and apply it with RabbitMQ environment variable - export RABBITMQ_CONFIG_FILE="/path/to/my_rabbitmq.conf
my_rabbitmq.conf
[{kernel,[{inet_dist_listen_min, 55950},{inet_dist_listen_min, 55950}]}].
Or you can use RabbitMQ Management Plugin. It is more functional and simple to setup.
I got this error trying to setup RabbitMQ on a cluster on an ubuntu and fedora machine:
el#apollo:/etc/rabbitmq$ sudo rabbitmqctl join_cluster rabbit#192.168.1.8
Clustering node rabbit#apollo with 'rabbit#192.168.1.8' ...
Error: unable to connect to nodes ['rabbit#192.168.1.8']: nodedown
DIAGNOSTICS
===========
attempted to contact: ['rabbit#192.168.1.8']
rabbit#192.168.1.8:
* unable to connect to epmd (port 4369) on 192.168.1.8: address
(cannot connect to host/port)
current node details:
- node name: rabbitmqctl7233#apollo
- home dir: /var/lib/rabbitmq
- cookie hash: g0tS9zEdo7OEDSZaDTGirA==
I was able to eliminate this error by opening the 4369 and 59984 port on the 192.168.1.8 machine that is one of the slave nodes of the cluster:
el#defiant ~ $ su -
Password:
[root#defiant ~]# iptables -I INPUT -p tcp --dport 4369 --syn -j ACCEPT
[root#defiant ~]# iptables -I INPUT -p tcp --dport 59984 --syn -j ACCEPT
Port 4369 was not enabled on firewall. When I switched firewall 'off'. Everything started working.
Just type docker exec -t rabbitmq sh
Then you will get access to the terminal of your docker environment.
Once you are in, type rabbitmqctl to see if it works
Hopefully it can help you.

Rabbit will not cluster on ec2

I am having server issues with getting rabbit to cluster.
I boot up two nodes on ec2.
On the the first node booted I do this.
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
I boot another node.
sudo service rabbitmq-server stop
#Copy cookie from the first server booted
sudo su - -c 'echo -n "cookie" > /var/lib/rabbitmq/.erlang.cookie'
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl cluster rabbit#server1
1) sever1 is running
2) What ports to need open? I have 22, 4369, 5672
sudo rabbitmqctl cluster rabbit#aws-rabbit-server-east-development-20121102162143
Clustering node 'rabbit#aws-rabbit-server-east-development-20121103033005' with ['rabbit#aws-rabbit-server-east-development-20121102162143'] ...
Error: {no_running_cluster_nodes,['rabbit#aws-rabbit-server-east-development-20121102162143'],
['rabbit#aws-rabbit-server-east-development-20121102162143']}
What could possibility be missing from there docs or what what am I missing?
I had a similar problem on EC2 with two windows machines. I eventually got it working but I'm not sure I did it in the correct way so there may be a better solution.
The issue I found was that the two nodes could not see each other when trying to cluster. Each time you start a Rabbit node it seemed to be assigned a port number dynamically.
This obviously makes it very difficult to know which port to open up in the security group so to solve this, I restricted the range of ports Rabbit chose from when assigning the port. I restricted this to a range of 1 port on each node so I always know which port was being assigned.
The easiest way I found to do this was by editing the sbin\rabbitmq-service.bat file.
find the line -kernel inet_default_connect_options "[{nodelay,true}]" ^
add the following two lines to the file underneath:
-kernel inet_dist_listen_min ##### ^
-kernel inet_dist_listen_max ##### ^
replacing ##### with your chosen port number.
So you should now open up the following ports:
5672 - RabbitMQ’s listening port
4369 - Erlang Port Mapper Daemon
##### - the chosen port number for the Erlang nodes to communicate via
Because Erlang does not recognise FQDNs you may need to modify the hosts file on all the servers to make sure they are all able to resolve all the Erlang node name to an IP address, e.g.
123.123.123.111 NODE1
123.123.123.222 NODE2
once this is done you should then be able to see each node from the other. you can do this by using calling the following from the command line (replacing rabbit#NODE2 with whichever node you want to see)
rabbitmqctl status -n rabbit#NODE2
Hope this give you some help, I'm no expert but found this got things working for me!