简体   繁体   English

Spring boot RabbitMQ Host 字符串格式

[英]Spring boot RabbitMQ Host string format

I am using spring boot to listen for messages on my rabbitmq instance.我正在使用 spring boot 来监听我的 rabbitmq 实例上的消息。 I have it working locally using an application.properties file.我使用application.properties文件在本地工作。

However, when I want to connect to the remote rabbit instance I am getting number format exceptions and unknown host exceptions because of my url.但是,当我想连接到远程兔子实例时,由于我的 url,我收到了数字格式异常和未知主机异常。

I've tried setting spring.rabbitmq.host to:我试过将spring.rabbitmq.host设置为:

amqp://myurl/dev and myurl/dev and amqp%3A%2F%2Fmyurl%2Fdev

Nothing is working.没有任何工作。 Any ideas what could be up.任何想法可能会发生什么。 I have set my user name and pass for the remote instance as well.我也为远程实例设置了我的用户名和密码。

Try removing the amqp:// part.尝试删除 amqp:// 部分。 The host property should just be that, the hostname:主机属性应该就是主机名:

spring.rabbitmq.host=myurl

Not sure what the /dev part is.不确定 /dev 部分是什么。 Are you saying that is your virtual-host?你是说那是你的虚拟主机? If so then just set this property too:如果是这样,那么也只需设置此属性:

spring.rabbitmq.virtual-host=dev

For username/password, set these properties:对于用户名/密码,设置这些属性:

spring.rabbitmq.username=
spring.rabbitmq.password=

A better way to do this is to set一个更好的方法是设置

spring.rabbitmq.addresses=amqps://user:password@10.0.0.123/virtualhost

This will get auto-resolved, and correctly set your hostname, password etc这将自动解决,并正确设置您的主机名、密码等

Github issue that fixes this: https://github.com/spring-projects/spring-boot/issues/6401解决此问题的 Github 问题: https : //github.com/spring-projects/spring-boot/issues/6401

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM