Trouble with Rabbit and Spring

Asked

Viewed 24 times

0

Talk about beauty?

I’m having a problem using my application with Rabbit via Docker.

Here’s what you get:

I created a Docker-Compose, it follows:

version: "3"

services:
  rabbitmq:
    image: rabbitmq:3-management
    hostname: rabbitmq
    ports:
      - "15672:15672"
      - "5672:5672"
    restart: on-failure
    networks: 
      - teste

  relay:
    build:
      context: .
      dockerfile: RelayDockerfile
    ports:
      - "8090:8090"
    restart: on-failure
    depends_on:
      - rabbitmq
      - mongodb
    environment:
      - MONGODB_URI=mongodb://camarguinho:camarguinho@mongodb:27017/
      - SPRING_RABBITMQ_PORT=5672
      - SPRING_RABBITMQ_HOST=rabbitmq
      - SPRING_RABBITMQ_USERNAME=guest
      - SPRING_RABBITMQ_PASSWORD=guest   
    networks: 
      - teste 

  mongodb:
    image: mongo:4.4.3
    environment:
      - MONGO_INITDB_DATABASE=component-db
      - MONGO_INITDB_ROOT_USERNAME=camarguinho
      - MONGO_INITDB_ROOT_PASSWORD=camarguinho
    ports:
      - "27017:27017"
    volumes:
      - ./mongod/config/mongod.conf:/etc/mongod.conf
    networks: 
      - teste

networks:
  teste:
    external:
      name: teste 

But when rotating docker-compose up, the application cannot connect to Rabbit. I put a println() - BEAUTIFUL DEBUG - to know which URL he was trying to connect to and the answer is: amqp://guest:guest@rabbitmq:5672/, just to make sure I was getting right.

I know with network_mode: host It works well because I have already tested, but I didn’t want to have to use this method where the application is in the same "network" as my machine. I wanted everything inside the Docker network.

Some solution guys?

  • Put project config and container error

  • The only error in the container is the Connection refused from the pro Rabbit application. Config is basically an application.yml expecting host variables, port, user, Rabbit pass. And I assure you that the connection Uri is arriving correctly: amqp://guest:guest@rabbitmq:5672/. But he doesn’t seem to see the Rabbit container inside the network.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.