如何解决Spring-cloud-sleuth-zipkin(Edgware.SR5)中的RabbitMQ Server连接错误

时间:2018-11-08 13:19:40

标签: spring-rabbitmq spring-cloud-sleuth

我需要通过RabbitMQ发送跨度到Zipkin。我正在使用Spring-Cloud-Sleuth Edgware-SR5版本和SpringBoot 1.5.3.RELEASE版本。 使用较旧的Spring-cloud sleuth版本(spring-cloud-stream-binder-rabbit-v1.1.4.RELEASE),它可以正常工作。

当我尝试启动服务时,我收到“ ” AsyncReporter {RabbitMQSender {addresses = [localhost:5672],queue = zipkin}}。无法建立与RabbitMQ服务器的连接”错误。 我已经阅读了文档,但是无法解决此问题。

版本配置:

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.SR5"
    }
}

compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile 'org.springframework.amqp:spring-rabbit'

Application.yml:

spring:
  sleuth:
    enabled: true
    async:
      enabled: true
  sampler:
    percentage: 1.0 
  zipkin:
    baseUrl: 
    sender:
      type: rabbit

异常StackTrace:

Exception in thread "AsyncReporter{RabbitMQSender{addresses=[localhost:5672], queue=zipkin}}" java.lang.IllegalStateException: Unable to establish connection to RabbitMQ server
    at zipkin2.reporter.amqp.RabbitMQSender.get(RabbitMQSender.java:190)
    at zipkin2.reporter.amqp.AutoValue_RabbitMQSender.get(AutoValue_RabbitMQSender.java:27)
    at zipkin2.reporter.amqp.RabbitMQSender$1.initialValue(RabbitMQSender.java:211)
    at zipkin2.reporter.amqp.RabbitMQSender$1.initialValue(RabbitMQSender.java:208)
    at java.lang.ThreadLocal.setInitialValue(Unknown Source)
    at java.lang.ThreadLocal.get(Unknown Source)
    at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.publish(RabbitMQSender.java:231)
    at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.doExecute(RabbitMQSender.java:226)
    at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.doExecute(RabbitMQSender.java:218)
    at zipkin2.Call$Base.execute(Call.java:379)
    at zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:272)
    at zipkin2.reporter.AsyncReporter$Builder$1.run(AsyncReporter.java:179)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:50)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:736)
    at zipkin2.reporter.amqp.RabbitMQSender.get(RabbitMQSender.java:188)

感谢和问候 Suresh

1 个答案:

答案 0 :(得分:1)

  

Connection refused: connect

仅表示RabbitMQ不在localhost:5672上运行(如果您没有在application.yml中为其提供主机/端口或地址,则为默认设置)。