使用tracing插件定位RabbitMQ问题

在定位某个问题的时候,我坚持说我已经把信息发到了RabbitMQ里,但是同事说没收到,只好打开了日志,用日志来定位问题。

首先启用tracing

./rabbitmq-pluginsenable rabbitmq_tracing


然后在management页面中查看admin/Tracing页面

使用tracing插件定位RabbitMQ问题_第1张图片

 

新增一个Trace,Trace的format设置为String即可

使用tracing插件定位RabbitMQ问题_第2张图片

 

日志的实际位置位于/var/tmp/rabbitmq-tracing/trace1.log,其每一条消息日志形如:


================================================================================
2017-06-05 15:03:12:233: Message published

Node:         rabbit@PlatformTest-RHEL-5
Connection:   100.2.92.111:15512 -> 100.2.91.184:5671
Virtual host: /
User:         xxx
Channel:      1
Exchange:     amq.direct
Routing keys: [<<"com:inspur:xxx:upstream:xx">>]
Routed queues: [<<"com:inspur:xxx:upstream:xx">>]
Properties:   [{<<"delivery_mode">>,signedint,2},
               {<<"content_type">>,longstr,<<"text/plain">>}]
Payload: 
{
    "msgid": "00000",
    "resid": "00000",
    "src": "yyy",
    "dest": "zzz",
    "cmd": "qqq",
    "time": "1496645805",
    "data":
    {
        "ip": "192.168.1.155"
    }
}

================================================================================
2017-06-05 15:03:12:233: Message received

Node:         rabbit@PlatformTest-RHEL-5
Connection:   127.0.0.1:47742 -> 127.0.0.1:5672
Virtual host: /
User:         xxx
Channel:      2
Exchange:     amq.direct
Routing keys: [<<"com:inspur:xxx:upstream:xx">>]
Queue:        com:inspur:xxx:upstream:xx
Properties:   [{<<"delivery_mode">>,signedint,2},
               {<<"content_type">>,longstr,<<"text/plain">>}]
Payload: 
{
    "msgid": "00000",
    "resid": "00000",
    "src": "yyy",
    "dest": "zzz",
    "cmd": "qqq",
    "time": "1496645805",
    "data":
    {
        "ip": "192.168.1.155"
    }
}



 总结一下IP地址和方法和消息方向的关系如下:

 

目的

方法

说明

127.0.0.1:47742

127.0.0.1:5672

Publish

服务端给MQ

127.0.0.1:47742

127.0.0.1:5672

Receive

MQ给服务端

100.2.92.111:61037

100.2.91.184:5671

Publish

客户端给MQ

100.2.92.111:22982

100.2.91.184:5671

Receive

MQ给客户端


你可能感兴趣的:(架构)