spring-cloud / spring-cloud/spring-cloud-consul
Circular dependencies between consul and mongodb health contributor
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 822
- Forks
- 539
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 7
Description
Description
If consul heartbeat it's configured to use actuator health(the default configuration) and we have some mongo repositories on classpath a circular dependency it's created between them:
The dependencies of some of the beans in the application context form a cycle:
apiController (field private com.sample.service.ReactiveAutenticationService com.sample.controller.ApiController.reactiveAutenticationService)
↓
reactiveAuthenticationServiceImpl (field private com.sample.repository.AccountRepository com.sample.service.ReactiveAuthenticationServiceImpl.accountRepository)
↓
accountRepository defined in com.sample.repository.AccountRepository defined in @EnableReactiveMongoRepositories declared on ApplicationEntryPoint
┌─────┐
| reactiveMongoTemplate defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]
↑ ↓
| mappingMongoConverter defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]
↑ ↓
| mongoMappingContext defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataConfiguration.class]
↑ ↓
| consulAutoServiceRegistrationListener defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulAutoServiceRegistrationAutoConfiguration.class]
↑ ↓
| consulAutoServiceRegistration defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulAutoServiceRegistrationAutoConfiguration.class]
↑ ↓
| consulServiceRegistry defined in class path resource [org/springframework/cloud/consul/serviceregistry/ConsulServiceRegistryAutoConfiguration.class]
↑ ↓
| ttlScheduler defined in class path resource [org/springframework/cloud/consul/support/ConsulHeartbeatAutoConfiguration.class]
↑ ↓
| actuatorHealthStatusProvider defined in class path resource [org/springframework/cloud/consul/support/ConsulHeartbeatAutoConfiguration$ActuatorBasedApplicationStatusProviderConfig.class]
↑ ↓
| healthEndpoint defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]
↑ ↓
| healthContributorRegistry defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]
↑ ↓
| mongoHealthContributor defined in class path resource [org/springframework/boot/actuate/autoconfigure/data/mongo/MongoReactiveHealthContributorAutoConfiguration.class]
└─────┘
If spring.cloud.consul.discovery.heartbeat.use-actuator-health it's set to false then the dependency chain it's broken and everything works.
Sample
Please check the repository here
Versions
Spring boot: 3.1.5
Spring cloud: 2022.0.4
Java: 17
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sample repository and reproduce the cycle using Spring Boot 3.1.5, Spring Cloud 2022.0.4, Java 17, Mongo repositories, and actuator health enabled. Trace the listed Consul heartbeat and Mongo health auto-configuration classes, then verify that the application starts with heartbeat actuator health enabled without requiring it to be set to false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb, spring, spring-boot
- Domain
- backend, databases, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100