{"id":902,"date":"2023-03-11T07:41:16","date_gmt":"2023-03-10T23:41:16","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=902"},"modified":"2023-04-29T15:52:51","modified_gmt":"2023-04-29T07:52:51","slug":"spring-cloud-message-bus-rabbitmq","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/11\/spring-cloud-message-bus-rabbitmq\/","title":{"rendered":"Spring Cloud\u6d88\u606f\u603b\u7ebfRabbitMQ\u65b9\u5f0f"},"content":{"rendered":"<p>\u56e0\u4e3a\u4e4b\u524d\u8bf4\u7684 Zipkin \u4e0d\u518d\u63a8\u8350\u6211\u4eec\u6765\u81ea\u5b9a\u4e49 Server \u7aef\u4e86\uff0c\u6240\u4ee5\u5728\u6700\u65b0\u7248\u672c\u7684 Spring Cloud \u4f9d\u8d56\u7ba1\u7406\u91cc\u5df2\u7ecf\u627e\u4e0d\u5230 zipkin-server \u4e86\u3002<br \/>\n\u90a3\u4e48\u5982\u679c\u76f4\u63a5\u4f7f\u7528\u5b98\u65b9\u63d0\u4f9b\u7684 jar \u5305\u600e\u4e48\u4ece RabbitMQ \u4e2d\u83b7\u53d6 trace \u4fe1\u606f\u5462\uff1f<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u8ba9 Zipkin \u4ece RabbitMQ \u4e2d\u8bfb\u53d6\u4fe1\u606f\uff0c\u5c31\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre><code>RABBIT_ADDRESSES=localhost java -jar zipkin.jar<\/code><\/pre>\n<p>\u53ef\u914d\u7f6e\u7684\u73af\u5883\u53d8\u91cf\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u5c5e\u6027<\/th>\n<th style=\"text-align: left;\">\u73af\u5883\u53d8\u91cf<\/th>\n<th style=\"text-align: left;\">\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.concurrency<\/td>\n<td style=\"text-align: left;\">RABBIT_CONCURRENCY<\/td>\n<td style=\"text-align: left;\">\u5e76\u53d1\u6d88\u8d39\u8005\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a1<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.connection-timeout<\/td>\n<td style=\"text-align: left;\">RABBIT_CONNECTION_TIMEOUT<\/td>\n<td style=\"text-align: left;\">\u5efa\u7acb\u8fde\u63a5\u65f6\u7684\u8d85\u65f6\u65f6\u95f4<br \/>\u9ed8\u8ba4\u4e3a 60000\u6beb\u79d2\uff0c\u5373 1 \u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.queue<\/td>\n<td style=\"text-align: left;\">RABBIT_QUEUE<\/td>\n<td style=\"text-align: left;\">\u4ece\u4e2d\u83b7\u53d6 span \u4fe1\u606f\u7684\u961f\u5217\uff0c\u9ed8\u8ba4\u4e3a zipkin<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.uri<\/td>\n<td style=\"text-align: left;\">RABBIT_URI<\/td>\n<td style=\"text-align: left;\">\u7b26\u5408 RabbitMQ URI \u89c4\u8303 \u7684 URI<br \/>\u4f8b\u5982 amqp:\/\/user:pass@host:10000\/vhost<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u8bbe\u7f6e\u4e86 URI\uff0c\u5219\u4ee5\u4e0b\u5c5e\u6027\u5c06\u88ab\u5ffd\u7565\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u5c5e\u6027<\/th>\n<th style=\"text-align: left;\">\u73af\u5883\u53d8\u91cf<\/th>\n<th style=\"text-align: left;\">\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.addresses<\/td>\n<td style=\"text-align: left;\">RABBIT_ADDRESSES<\/td>\n<td style=\"text-align: left;\">\u7528\u9017\u53f7\u5206\u9694\u7684 RabbitMQ \u5730\u5740\u5217\u8868<br \/>\u4f8b\u5982localhost:5672,localhost:5673<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.password<\/td>\n<td style=\"text-align: left;\">RABBIT_PASSWORD<\/td>\n<td style=\"text-align: left;\">\u8fde\u63a5\u5230 RabbitMQ \u65f6\u4f7f\u7528\u7684\u5bc6\u7801\uff0c\u9ed8\u8ba4\u4e3a guest<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.username<\/td>\n<td style=\"text-align: left;\">RABBIT_USER<\/td>\n<td style=\"text-align: left;\">\u8fde\u63a5\u5230 RabbitMQ \u65f6\u4f7f\u7528\u7684\u7528\u6237\u540d\uff0c\u9ed8\u8ba4\u4e3aguest<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.virtual-host<\/td>\n<td style=\"text-align: left;\">RABBIT_VIRTUAL_HOST<\/td>\n<td style=\"text-align: left;\">\u4f7f\u7528\u7684 RabbitMQ virtual host\uff0c\u9ed8\u8ba4\u4e3a \/<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">zipkin.collector.rabbitmq.use-ssl<\/td>\n<td style=\"text-align: left;\">RABBIT_USE_SSL<\/td>\n<td style=\"text-align: left;\">\u8bbe\u7f6e\u4e3atrue\u5219\u7528 SSL \u7684\u65b9\u5f0f\u4e0e RabbitMQ \u5efa\u7acb\u94fe\u63a5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u4e8e Zipkin \u7684 Client \u7aef\uff0c\u4e5f\u5c31\u662f\u5fae\u670d\u52a1\u5e94\u7528\uff0c\u6211\u4eec\u5c31\u5728\u4e4b\u524d trace-a\u3001trace-b \u7684\u57fa\u7840\u4e0a\u4fee\u6539\uff0c\u53ea\u8981\u5728\u4ed6\u4eec\u7684\u4f9d\u8d56\u91cc\u90fd\u5f15\u5165<code>spring-cloud-stream-binder-rabbit<\/code>\u5373\u53ef\uff0c\u522b\u7684\u4e0d\u7528\u4fee\u6539\u3002<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-cloud-stream-binder-rabbit&lt;\/artifactId&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>\u4e0d\u8fc7\u4e3a\u4e86\u8bf4\u660e\u662f\u901a\u8fc7 RabbitMQ \u4f20\u8f93\u7684\u4fe1\u606f\uff0c\u6211\u4eec\u5c06<code>spring.zipkin.base-url<\/code>\u5747\u6539\u4e3a<code>http:\/\/localhost:9412\/<\/code>\uff0c\u5373\u6307\u5411\u4e00\u4e2a\u9519\u8bef\u7684\u5730\u5740\u3002<\/p>\n<p>\u5206\u522b\u91cd\u542f trace-a\u3001trace-b \u5de5\u7a0b\uff0c\u5e76\u542f\u52a8 Zipkin Server<\/p>\n<pre><code>RABBIT_ADDRESSES=localhost java -jar zipkin.jar<\/code><\/pre>\n<p>\u7136\u540e\u8bbf\u95ee<code>http:\/\/localhost:8080\/trace-a<\/code>\u5e76\u5237\u65b0 Zipkin UI\uff0c\u770b\u5230\u5982\u4e0b\u5185\u5bb9\uff0c\u5c31\u8bf4\u660e <code>Sleuth+Zipkin+RabbitMQ<\/code> \u6574\u5408\u6210\u529f\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/Sleuth-Zipkin-RabbitMQ.jpeg\" alt=\"Sleuth+Zipkin+RabbitMQ\" \/><\/p>\n<p>\u6b64\u65f6\u770b RabbitMQ Admin\uff0c\u4f1a\u770b\u5230\u591a\u4e86\u4e00\u4e2a\u540d\u4e3a zipkin \u7684 Queue<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/Java\/Zipkin-RabbitMQ-Admin.jpeg\" alt=\"RabbitMQ Admin\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u4e4b\u524d\u8bf4\u7684 Zipkin \u4e0d\u518d\u63a8\u8350\u6211\u4eec\u6765\u81ea\u5b9a\u4e49 Server \u7aef\u4e86\uff0c\u6240\u4ee5\u5728\u6700\u65b0\u7248\u672c\u7684 Spring Clou [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[245],"class_list":["post-902","post","type-post","status-publish","format-standard","hentry","category-spring-cloud","tag-rabbitmq"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=902"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/902\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}