【问题标题】:Get IP of producers sending messages to queue/exchange获取向队列/交换发送消息的生产者的 IP
【发布时间】:2018-11-02 21:42:38
【问题描述】:

出于故障排除的目的,我想获取向特定队列或交换器发送消息的生产者列表。我在 rabbitmq 控制台中没有看到任何选项来获取上述详细信息。一些生产者正在堆积一个特定的队列,我正在试图找出生产者在队列中堆积消息的 IP。

谁能指导我。

【问题讨论】:

    标签: rabbitmq


    【解决方案1】:

    默认情况下您没有此信息,但您可以使用邮件标题来执行此操作。

    例如:

    string message = "Hello World!";
    var body = Encoding.UTF8.GetBytes(message);
    
    var properties = new BasicProperties();
    properties.Headers = new Dictionary<string, object>();
    properties.Headers.Add("senderip", InetAddress.getLocalHost().getHostAddress());
    properties.Headers.Add("custominfo", "info" );
    
    channel.BasicPublish(exchange: "", routingKey: "mykey", basicProperties: properties,body: body);
    

    当您收到消息时,您可以对标头进行解码

    【讨论】:

      猜你喜欢
      • 2013-02-21
      • 2016-12-10
      • 2015-03-19
      • 2019-05-20
      • 1970-01-01
      • 2021-11-25
      • 2013-03-10
      • 2021-08-30
      • 2019-10-03
      相关资源
      最近更新 更多