下面是用于在 spark scala 中測驗 Rabbitmq 連接的代碼。
import com.rabbitmq.client.ConnectionFactory
def getRabbitMQConnection()={
val factory = new ConnectionFactory()
factory.setUsername("****")
factory.setPassword("****")
factory.setHost("***")
factory.setVirtualHost("5672")
val connection = factory.newConnection()
}
當我嘗試連接時,出現以下錯誤。
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - access to vhost '5672' refused for user '****', class-id=10, method-id=40)
有人可以幫忙嗎?
謝謝你。
uj5u.com熱心網友回復:
access to vhost '5672' refused for user '****'
我認為您將 TCP 埠與虛擬主機混淆了。
嘗試:
factory.setVirtualHost("/")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/413851.html
標籤:
上一篇:如何在Scala中創建泛型類
下一篇:【技巧總結】java位運算
