fiz conforme detalhado na aula , mas nao aparece a fila de conexao
Segue os codigos: pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
application.properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/${MYSQL_DATABASE}?createDatabaseIfNotExist=true
spring.datasource.username=${MSQL_USERNAME}
spring.datasource.password=${MYSQL_PASSWORD}
spring.jpa.show-sql=true
#Configurate Eureka Server:
spring.application.name=payments-ms
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.serviceUrl.defaultZone=http://localhost:8081/eureka
spring.config.import=optional:file:.env[.properties]
#Properties RabbitMQ configuration:
spring.rabbitmq.host=${RABBITMQ_LOCALHOST}
spring.rabbitmq.port=${RABBITMQ_PORT}
spring.rabbitmq.username=${RABBITMQ_USERNAME}
spring.rabbitmq.password=${RABBITMQ_PASSWORD}
#permit that Eureka manages the default port:
server.port=0
# Enable all Actuator endpoints
management.endpoints.web.exposure.include=*
#configuring CircuitBreaker:
#slidingWindowSize: Defines the number of requests used to calculate the failure rate.
#minimumNumberOfCalls: Minimum number of calls required before evaluating the state.
#waitDurationInOpenState: Time to wait in the open state before testing again.
resilience4j.circuitbreaker.instances.updateOrder.slidingWindowSize=3
resilience4j.circuitbreaker.instances.updateOrder.minimumNumberOfCalls=2
resilience4j.circuitbreaker.instances.updateOrder.waitDurationInOpenState=50s
meu arquivo .env:
MYSQL_DATABASE=payment-db
MSQL_USERNAME=root
MYSQL_PASSWORD=
RABBITMQ_LOCALHOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=rodrigo
RABBITMQ_PASSWORD=1312
Classe de configuracao do AMQP:
package com.goodfood.payments.amqp;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
public class PaymentAMQPConfiguration {
@Bean
public Queue createQueue() {
//return new Queue("payment.completed", false);
return QueueBuilder.nonDurable("payment.completed").build();
}
@Bean
public RabbitAdmin createRabbitAdmin(ConnectionFactory conn) {
return new RabbitAdmin(conn);
}
@Bean
public ApplicationListener<ApplicationReadyEvent> initializeAdmin(RabbitAdmin rabbitAdmin) {
return event -> rabbitAdmin.initialize();
}
}
Estou rodando o container docker no ubuntu:
version: "3.6"
services:
rabbitmq:
image: rabbitmq:4.0-management
container_name: rabbitmq
restart: always
ports:
- 5672:5672 # Porta para conexões do RabbitMQ
- 15672:15672 # Porta para a interface de gerenciamento
volumes:
- ./data/rabbitmq:/var/lib/rabbitmq/mnesia # Persistência de dados
environment:
- RABBITMQ_DEFAULT_USER=rodrigo # Usuário padrão
- RABBITMQ_DEFAULT_PASS=1312 # Senha padrãpp
Tambem tenho uma duvida, pois o microsservico de pagamento esta configurado para integrar com o Eureka service, devo manter essa configuracao?