Availability of virtual threads made me want to switch from reactive Spring Cloud Gateway to it’s MVC version. Migration of most of the code was easy (changing some classes and method names, moving routes configuration from spring.cloud.gateway.routes
to spring.cloud.gateway.mvc.routes
), but one thing that doesn’t seem to work is simple discovery client for load balancing for routes.
Every time I try to access route that is using load balancing I get error like:
org.springframework.web.client.HttpServerErrorException: 503 Unable to find instance for dashboard-backend
How can I use simple discovery client work in Spring Cloud Gateway MVC? (I don’t want to use external discovery clients.)
Configuration that I use:
spring:
application:
name: test-application
threads:
virtual:
enabled: true
cloud:
loadbalancer:
configurations: health-check
discovery:
client:
simple:
instances:
dashboard-backend:
- instanceId: dashboard-backend-1
serviceId: dashboard-backend
uri: http://localhost:8081
- instanceId: dashboard-backend-2
serviceId: dashboard-backend
uri: http://localhost:8082
gateway:
mvc:
routes:
- id: dashboard-backend
uri: lb://dashboard-backend
predicates:
- Path=/api/**
Krzysztof is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.