Я пытался настроить эту функцию в своем AccountController
Код: Выделить всё
@PostMapping("/create/{userID}")
@CircuitBreaker(name = "accountService")
public ResponseEntity createAccount(@RequestBody AccountDTO account, @PathVariable Long userID) {
log.info("Creating account for user ID: {}", userID);
CashUserDTO user = cashUserServiceProxy.findById(userID);
if (user == null) {
log.error("User not found for ID: {}", userID);
return new ResponseEntity("No user found.", HttpStatus.BAD_REQUEST);
} else {
AccountDTO createdAccount = accountsService.createAccount(account, userID);
EntityModel model = toModel(createdAccount, userID);
return new ResponseEntity(model, HttpStatus.OK);
}
}
Код: Выделить всё
spring.application.name=accountService
spring.config.import=optional:configserver:http://localhost:8070/
server.port=8083
management.health.circuitbreakers.enabled=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=health
spring.datasource.url=jdbc:mysql://localhost:3306/cashmate
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=validate
spring.sql.init.mode=never
spring.sql.init.platform=mysql
resilience4j.circuitbreaker.configs.default.register-health-indicator=true
resilience4j.circuitbreaker.instances.accountService.minimum-number-of-calls=5
resilience4j.circuitbreaker.instances.accountService.failure-rate-threshold=70
resilience4j.circuitbreaker.instances.accountService.wait-duration-in-open-state=10000
resilience4j.circuitbreaker.instances.accountService.permitted-number-of-calls-in-half-open-state=1
management.tracing.sampling.probability=1.0
Код: Выделить всё
{"status":"UP","components":{"clientConfigServer":{"status":"UP","details":{"propertySources":["configClient"]}},"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"isValid()"}},"discoveryComposite":{"status":"UP","components":{"discoveryClient":{"status":"UP","details":{"services":[]}},"eureka":{"description":"Eureka discovery client has not yet successfully connected to a Eureka server","status":"UP","details":{"applications":{}}}}},"diskSpace":{"status":"UP","details":{"total":290824646656,"free":289731194880,"threshold":10485760,"path":"D:\\coding\\CashMateCloud\\config-server\\.","exists":true}},"ping":{"status":"UP"},"reactiveDiscoveryClients":{"status":"UP","components":{"Simple Reactive Discovery Client":{"status":"UP","details":{"services":[]}},"Spring Cloud Eureka Reactive Discovery Client":{"status":"UP","details":{"services":[]}}}},"refreshScope":{"status":"UP"}}}
Подробнее здесь: https://stackoverflow.com/questions/786 ... pplication