I am starting a container for rabbitmq and another with my spring boot service using the following docker-compose.yaml
version: '3'
services:
messaging:
image: "messaging"
ports:
- "7878:9876"
depends_on:
- rmq
rmq:
image: "rabbitmq:management"
hostname: "rabbitmqhost"
container_name: "rabbit-mq"
ports:
- "15672:15672"
- "5672:5672"
Now rabbitmq management is accessible at http://localhost:15672/
and the service is accessible at http://localhost:7878
The service is supposed to push messages into rabbitmq. When I hit the restAPI http://localhost:7878/sendPersonDetails
it is unable to connect to rabbitmq.
Following is the error response I am getting-
error occurred in message handler [org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint@3e66d8c7]; nested exception is org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
Following is my application.properties
file-
spring.cloud.stream.bindings.output.destination=person
spring.cloud.stream.bindings.output.content-type=application/json
server.port=9876
How do I change my docker-compose configuration or service configuration to make it work? Any help's appreciated.