I started RabbitMq on docker. This is the output of docker ps
:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
93dcba1c9b74 rabbitmq:3 "docker-entrypoint.s…" About a minute ago Up 9 seconds 4369/tcp, 5671-5672/tcp, 25672/tcp rabbitTestQueue
Then I used Scala code of op-rabbit with the following configuration in application.conf:
-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
}
}
This is my code:
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
}
}
}
}
}
When I run my code, I get the following error:
akka://MainApp/user/$a/connection in Disconnected received Connect: can't connect to amqp://guest@{rabbitTestHost:5672}:5672//, retrying in 10 seconds
How can I solve this issue? Should I change some configuration in application.conf
?
The RabbitMQ team monitors the rabbitmq-users
mailing list and only sometimes answers questions on StackOverflow.
Based on this message:
Connect: can't connect to amqp://guest@{rabbitTestHost:5672}:5672//
It looks as though the value of ["rabbitTestHost"]
is rabbitTestHost:5672
when it should be just rabbitTestHost
. Notice that 5672
is duplicated in the connect message.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加