我有一个 docker container runnig spring app consumer 但是当我想用邮递员 http://localhost:8087/queues/projqueue/size 测试这个 API 时我得到连接错误
2023-03-14 10:28:32.959 ERROR 1 --- [nio-8087-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)] with root cause
java.net.ConnectException: Connection refused '192.168.0.100' (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_212]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:59) ~[amqp-client-5.16.0.jar!/:5.16.0]
我试过这个命令来运行 rabbitmq 容器
docker run -d --hostname haroldjcastillo --name rabbit-server -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin2017 -p 5672:5672 -p 15672:15672 rabbitmq:3-management
然后我将 application.propties 更改为
spring.application.name=event-service-receiver
spring.rabbitmq.host=192.168.0.100 (here i tried sevral host like rabbitmq,rabbit-server(wich is the name of the container)a)
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
server.port=8087
即使我可以访问 rabbitmq UI 管理 nslookup 也不起作用
nslookup rabbit-server
Server: dns.google
Address: 8.8.8.8
*** dns.google can't find rabbit-server: Non-existent domain
在此先感谢您的任何帮助