Я пытаюсь добавить Eureka Service для моих микросервисов, однако, даже если микросервисы работают и обмен сообщениями работает должным образом, Eureka не может обнаружить службу, потому что они не работают? Это вывод http://localhost: 8080 / привод / здоровье
{
"status": "DOWN",
"components": {
"binders": {
"status": "UP",
"components": {
"rabbit": {
"status": "UP",
"details": {
"version": "3.7.8"
}
}
}
},
"coreServices": {
"status": "DOWN",
"details": {
"movie": {
"status": "DOWN",
"details": {
"error": "io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: movie/172.21.0.8:80"
}
},
"reviews": {
"status": "DOWN",
"details": {
"error": "io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: review/172.21.0.9:80"
}
},
"recommendations": {
"status": "DOWN",
"details": {
"error": "io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: recommendation/172.21.0.6:80"
}
}
}
},
"discoveryComposite": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN",
"components": {
"discoveryClient": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN"
}
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 84014424064,
"free": 28400906240,
"threshold": 10485760
}
},
"ping": {
"status": "UP"
},
"rabbit": {
"status": "UP",
"details": {
"version": "3.7.8"
}
},
"reactiveDiscoveryClients": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN",
"components": {
"Simple Reactive Discovery Client": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN"
}
}
}
}
}
Почему это так? запустив docker ps все они доступны:
(base) mat@mat-Vostro-5471:~/Projects/movie-rest-services$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
376da889ce8c movie-rest-services_review "java -jar /app.jar" 23 minutes ago Up 23 minutes 8080/tcp movie-rest-services_review_1
f4fe8c2668f2 movie-rest-services_movie "java -jar /app.jar" 23 minutes ago Up 23 minutes 8080/tcp movie-rest-services_movie_1
b2fa74bdb3ea movie-rest-services_movie-composite "java -jar /app.jar" 23 minutes ago Up 23 minutes 0.0.0.0:8080->8080/tcp movie-rest-services_movie-composite_1
d45062ca4e0c movie-rest-services_recommendation "java -jar /app.jar" 23 minutes ago Up 23 minutes 8080/tcp movie-rest-services_recommendation_1
a16db364e277 movie-rest-services_eureka "java -jar /app.jar" 23 minutes ago Up 23 minutes 0.0.0.0:8761->8761/tcp movie-rest-services_eureka_1
fd6b45ade9c3 rabbitmq:3.7.8-management "docker-entrypoint.s…" 23 minutes ago Up 23 minutes (healthy) 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp movie-rest-services_rabbitmq_1
68c9e3e92256 mongo:3.6.9 "docker-entrypoint.s…" 23 minutes ago Up 23 minutes (healthy) 0.0.0.0:27017->27017/tcp movie-rest-services_mongodb_1
2ad058b543d8 mysql:5.7 "docker-entrypoint.s…" 23 minutes ago Up 23 minutes (healthy) 0.0.0.0:3306->3306/tcp, 33060/tcp movie-rest-services_mysql_1
все мои микросервисы, включая композитные, имеют конфигурацию spring.application.name и eureka, например:
spring.application.name: movie
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
initialInstanceInfoReplicationIntervalSeconds: 5
registryFetchIntervalSeconds: 5
instance:
leaseRenewalIntervalInSeconds: 5
leaseExpirationDurationInSeconds: 5
и приложение службы Eureka выглядит следующим образом:
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
# from: https://github.com/spring-cloud-samples/eureka/blob/master/src/main/resources/application.yml
server:
waitTimeInMsWhenSyncEmpty: 0
response-cache-update-interval-ms: 5000
management.endpoints.web.exposure.include: "*"
Я проверяю, работает ли микросервис как вверх или вниз (я буду придерживаться описанного выше примера mov ie):
private Mono<Health> getHealth(String url) {
url += "/actuator/health";
log.info("Will call the Health API on URL: {}", url);
return getWebClient().get().uri(url).retrieve().bodyToMono(String.class)
.map(s -> new Health.Builder().up().build())
.onErrorResume(ex -> Mono.just(new Health.Builder().down(ex).build()))
.log();
}
где url: private final String MOVIE_SERVICE_URL = "http://movie";
, который выдаст:
movie-composite_1 | 2020-02-11 18:03:07.251 INFO 1 --- [or-http-epoll-6] c.g.m.c.m.s.MovieCompositeIntegration : Will call the Health API on URL: http://movie/actuator/health
movie-composite_1 | 2020-02-11 18:03:07.253 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.4 : onSubscribe(FluxOnErrorResume.ResumeSubscriber)
movie-composite_1 | 2020-02-11 18:03:07.253 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.4 : request(unbounded)
movie-composite_1 | 2020-02-11 18:03:07.256 INFO 1 --- [or-http-epoll-6] c.g.m.c.m.s.MovieCompositeIntegration : Will call the Health API on URL: http://recommendation/actuator/health
movie-composite_1 | 2020-02-11 18:03:07.257 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.5 : onSubscribe(FluxOnErrorResume.ResumeSubscriber)
movie-composite_1 | 2020-02-11 18:03:07.257 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.5 : request(unbounded)
movie-composite_1 | 2020-02-11 18:03:07.260 INFO 1 --- [or-http-epoll-6] c.g.m.c.m.s.MovieCompositeIntegration : Will call the Health API on URL: http://review/actuator/health
movie-composite_1 | 2020-02-11 18:03:07.261 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.6 : onSubscribe(FluxOnErrorResume.ResumeSubscriber)
movie-composite_1 | 2020-02-11 18:03:07.261 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.6 : request(unbounded)
movie-composite_1 | 2020-02-11 18:03:07.265 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.4 : onNext(DOWN {error=io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: movie/172.21.0.8:80})
movie-composite_1 | 2020-02-11 18:03:07.266 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.4 : onComplete()
movie-composite_1 | 2020-02-11 18:03:07.266 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.5 : onNext(DOWN {error=io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: recommendation/172.21.0.6:80})
movie-composite_1 | 2020-02-11 18:03:07.266 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.5 : onComplete()
movie-composite_1 | 2020-02-11 18:03:07.267 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.6 : onNext(DOWN {error=io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: review/172.21.0.9:80})
movie-composite_1 | 2020-02-11 18:03:07.273 INFO 1 --- [or-http-epoll-6] reactor.Mono.OnErrorResume.6 : onComplete()
Можете ли вы дать мне подсказку по этому поводу? Все тесты пройдены, и mvn clean install также прошла успешно.