Scala 已断开接收的连接:无法连接到amqp://guest@{rabbitesthost:5672}:5672

Scala 已断开接收的连接:无法连接到amqp://guest@{rabbitesthost:5672}:5672,scala,rabbitmq,Scala,Rabbitmq,我在docker上启动了RabbitMq。这是docker ps的输出: 然后,我在application.conf中使用的Scala代码具有以下配置: -rabbit { topic-exchange-name = "rabbitTestQueue" channel-dispatcher = "op-rabbit.default-channel-dispatcher" default-channel-dispatcher { type = Dispatcher e

我在docker上启动了RabbitMq。这是docker ps的输出:

然后,我在application.conf中使用的Scala代码具有以下配置:

-rabbit {
  topic-exchange-name = "rabbitTestQueue"
  channel-dispatcher = "op-rabbit.default-channel-dispatcher"
  default-channel-dispatcher {
    type = Dispatcher

    executor = "fork-join-executor"

    fork-join-executor {
      parallelism-min = 2
      parallelism-factor = 2.0
      parallelism-max = 4
    }
    throughput = 100
  }
  connection {
    virtual-host = "/"
    hosts = ["rabbitTestHost"]
    #username = "guest"
    #password = "guest"
    port = 5672
    ssl = false
    connection-timeout = 3s
  }
}
这是我的代码:

import akka.actor.{ActorSystem, Props}
import com.spingo.op_rabbit._
import scala.concurrent.ExecutionContext
import play.api.libs.json._

case class Query(query: String)

object MainApp extends App {
  import PlayJsonSupport._
  implicit val actorSystem = ActorSystem("KaliumApp")
  implicit val dataFormat = Json.format[Query]

  val rabbitControl = actorSystem.actorOf(Props(new RabbitControl))
  implicit val recoveryStrategy = RecoveryStrategy.nack(false)
  import ExecutionContext.Implicits.global

  val queryQueue = Queue("rabbitTestQueue", durable = false, autoDelete = true)
  val subscription = Subscription.run(rabbitControl) {
    import Directives._
    channel(qos=3) {
      consume(queryQueue) {
        body(as[Query]) { queryObj =>
          println(s"received ${queryObj.query}")
          ack
        }
      }
    }
  }
}
当我运行代码时,出现以下错误:

akka://MainApp/user/$a/connection in Disconnected received Connect: can't connect to amqp://guest@{rabbitTestHost:5672}:5672//, retrying in 10 seconds

我如何解决这个问题?我是否应该更改application.conf中的一些配置?

RabbitMQ团队监视并有时只回答有关StackOverflow的问题

基于此消息:

Connect: can't connect to amqp://guest@{rabbitTestHost:5672}:5672//

[rabbitesthost]的值似乎是rabbitesthost:5672,而它应该是rabbitesthost。请注意,连接消息中的5672是重复的。

RabbitMQ团队监视并有时只回答有关StackOverflow的问题

基于此消息:

Connect: can't connect to amqp://guest@{rabbitTestHost:5672}:5672//
[rabbitesthost]的值似乎是rabbitesthost:5672,而它应该是rabbitesthost。请注意,连接消息中的5672是重复的。

amqp://guest@{rabbitesthost:5672}:5672//

5672在此不重复,这只是打印连接日志的方式。

amqp://guest@{rabbitesthost:5672}:5672//

5672在这里不重复,这只是打印连接日志的方式