rabbitmq消息追踪

一旦开启,会影响性能,除非需要分析的时候才开启,否则不开启

一、firehose:不常用

rabbitmq消息追踪_第1张图片

二、rabbitmq_tracing:较常用

可通过管理界面查看分析,其实底层就是firehose,只不过可以用界面查看更方便

1、开启rabbitmq_tracing

进入rabbitmq的sbin文件夹。我的目录为D:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.5\sbin,打开cmd窗口,执行如下命令。然后重启mq

rabbitmq-plugins enable rabbitmq_tracing

rabbitmq消息追踪_第2张图片

2、浏览器打开http://localhost:15672,点击Admin

rabbitmq消息追踪_第3张图片

界面会增加一个Tracing按钮

3、添加一个trace

rabbitmq消息追踪_第4张图片

1、format:一般选择text模式方便人去查看;json模式进行base64编码,是方便以后导出用来做程序分析的
2、max那个不用写
3、pattern:用#,表示无论是发起方发送消息还是接收方接收消息,都做记录;用publish.#,表示只记录发起方发送记录;用deliver.#,表示只记录接收方处理记录

添加后如下图:
rabbitmq消息追踪_第5张图片

4、查看log文件

直接点击“Trace log files”下面的列表查看对应的日志文件,如:test.log

发送

================================================================================
2019-11-13 7:10:14:036: Message published

Node: rabbit@hkgi-PC
Connection: 127.0.0.1:12452 -> 127.0.0.1:5672
Virtual host: testhost
User: admin
Channel: 2
Exchange:
Routing keys: [<<“OrderQueue1”>>]
Routed queues: [<<“OrderQueue1”>>]
Properties: [{<<“priority”>>,signedint,0},
{<<“delivery_mode”>>,signedint,2},
{<<“headers”>>,table,
[{<<“X-B3-ParentSpanId”>>,longstr,<<“31b1b0a9699c2d3f”>>},
{<<“X-B3-Sampled”>>,longstr,<<“1”>>},
{<<“spring_listener_return_correlation”>>,longstr,
<<“c5d011b7-3052-4186-89a7-1708a3a8ebac”>>},
{<<“X-B3-TraceId”>>,longstr,<<“31b1b0a9699c2d3f”>>},
{<<“X-B3-SpanId”>>,longstr,<<“55083fa909f05ab2”>>}]},
{<<“content_encoding”>>,longstr,<<“UTF-8”>>},
{<<“content_type”>>,longstr,<<“text/plain”>>}]
Payload:
bbbbbbbbbbbbbb
接收

================================================================================
2019-11-13 7:10:14:036: Message received

Node: rabbit@hkgi-PC
Connection: 127.0.0.1:12452 -> 127.0.0.1:5672
Virtual host: testhost
User: admin
Channel: 1
Exchange:
Routing keys: [<<“OrderQueue1”>>]
Queue: OrderQueue1
Properties: [{<<“priority”>>,signedint,0},
{<<“delivery_mode”>>,signedint,2},
{<<“headers”>>,table,
[{<<“X-B3-ParentSpanId”>>,longstr,<<“31b1b0a9699c2d3f”>>},
{<<“X-B3-Sampled”>>,longstr,<<“1”>>},
{<<“spring_listener_return_correlation”>>,longstr,
<<“c5d011b7-3052-4186-89a7-1708a3a8ebac”>>},
{<<“X-B3-TraceId”>>,longstr,<<“31b1b0a9699c2d3f”>>},
{<<“X-B3-SpanId”>>,longstr,<<“55083fa909f05ab2”>>}]},
{<<“content_encoding”>>,longstr,<<“UTF-8”>>},
{<<“content_type”>>,longstr,<<“text/plain”>>}]
Payload:
bbbbbbbbbbbbbb

5、关闭rabbitmq_tracing:记住,查看完后要关闭,否则影响消息写入性能

进入rabbitmq的sbin文件夹。我的目录为D:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.5\sbin,打开cmd窗口,执行如下命令。然后重启mq

rabbitmq-plugins disable rabbitmq_tracing

你可能感兴趣的:(rabbitmq,rabbitmq,java-rabbitmq)