Closed spencergibb closed 4 years ago
Apparently, this is caused by an issue when the forwarding-metadata is read from the application.yml
.
The problem is that the route of the endpoint that reservation-service
exposes contains dots, create.reservation.{version}
.
Specifying forwarding information in reservation-service-client
's application.yml
as follows:
spring:
cloud:
gateway:
rsocket:
client:
forwarding:
create.reservation.{version}: # <-- here is the problem
service_name: reservation-service
canary: false
... causes the issue. After all, this is still yaml, and hence create.reservation.{version}
is a kind of hierarchy that, I guess, is not properly handled internally. As a result the client does not send the proper routing metadata and the Gateway's routing table goes berserk.
I am leaving this issue open, since a NullPointer should not be thrown whatsoever. But I will open another issue, that explains the issue (and provides a sample) with the dots in the route.
I'm positive it's not the dots since boots logging config supports them.
Turns out boot doesn't use config props for that, so, more investigation.
Here is the solution, it is based on boot's yaml parsing:
spring:
cloud:
gateway:
rsocket:
client:
forwarding:
"[create.reservation.{version}]":
service_name: reservation-service
canary: false
Great, thanks a lot for investigating this.
I'd suggest to also add this to the future documentation of Spring Cloud RSocket as well, since it is definitely not straight forward to find and given that Spring Core RSocket's @MessageMapping
advertises dotted routes, this will likely be a common problem. Additionally, with the NPE now caught, this will even silently fail if people configure the forwarding wrongly (like in my case).
Edit: Ok, sorry, just saw you already renamed my other issue and added the documentation tag to it.
See #4
@FWinkler79 said: I am using ... Spring Boot: 2.2.0.RELEASE Spring Cloud: Hoxton.BUILD-SNAPSHOT Sample project: here
My setup is as follows:
service-gateway
is an RSocket broker-enabed SCGreservation-service
exposes an RSocket endpoint to create a reservationreservation-service-client
exposes a Web-endpoint (WebFlux-based) toPOST
a reservation-creation request, which will be translated into an RSocket-request. The request should traverse gateway and reachreservation-service
reservation-service-client
uses declarative forwarding / routing metadata in itsapplication.yml
When running this setup, I receive the following
NullPointerException
in SCG:To reproduce, proceed as follows:
service-gateway
reservation-service
reservation-service-client
POST
request tohttp://localhost:6666/reservation/create/Michael