我需要使用 rabbit mq ctl 将队列映射到消费者的 ip。
在UI中,我可以在消费者标签中看到这一点,它为我提供了IP和端口。
使用兔子 mq ctl list_queues -> 给了我队列和频道名称
rabbitmqctl list_queues
q1 <rabbit@sg-rabbitmq-0.1.32026.83>
list_consumers -> 为我提供了带有通道 ID 的队列的使用者列表
rabbitmqctl list_consumers
q1 <rabbit@sg-rabbitmq-0.1.23140.1150> amq.ctag-efPo6z_2JPGTP_Rt02yjdA true 1 []
list_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
如何获取为其创建此通道的连接和 ip?
想通了,需要传递连接参数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
使用与 grep 的连接来对抗连接,提供 ip 详细信息
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
其中 rabbit@sg-rabbitmq-0.1.31144.1148 是连接 ID。