spring-cloud-rsocket icon indicating copy to clipboard operation
spring-cloud-rsocket copied to clipboard

Document forwarding metadata with dots in keys

Open FWinkler79 opened this issue 6 years ago • 1 comments

I am using ... Spring Boot: 2.2.0.RELEASE Spring Cloud: Hoxton.BUILD-SNAPSHOT Sample project: here "Fixed" project: here

I tried to follow the presentation and declarative routing information as shown here at the Spring One conference.

There is an issue with declarative routing / forwarding information specified in application.yml of an RSocket client, if the route contains dots (.).

Above you can find a sample that consists of the following components:

  1. reservation-service - an RSocket client exposing an endpoint by the route create.reservation that will be called by reservation-service-client via the gateway.
  2. reservation-service-client - an RSocket client exposing a WebFlux API to receive POST requests that get translated into an RSocket request to reservation-service.
  3. service-gateway - the RSocket broker-enabled SCG

With reservation-service-client's application.yml specifying the following routing metadata the gateway will fail forwarding the request with a NullPointerException since the client does not send the routing metadata properly:

spring:
  cloud:
    gateway:
      rsocket:
        client:
          forwarding:
            create.reservation:
              service_name: reservation-service
              canary: false

The issue is in the dotted syntax of the route, which in a Yaml file gets interpreted as a hierarchy. I guess the matching between the client's called route, and the routing information in Yaml therefore fails.

A working sample is also given above, which uses dashes instead of dots.

To reproduce:

  1. start service-gateway
  2. start reservation-service
  3. start reservation-service-client
  4. Send a POST request with empty body to http://localhost:6666/reservation/create/RSocketRules

See also #1 which is related, but note that it additionally uses dynamic parts in the route.

FWinkler79 avatar Oct 22 '19 11:10 FWinkler79

See https://github.com/spring-cloud-incubator/spring-cloud-rsocket/issues/1#issuecomment-545088882 for the solution.

spencergibb avatar Oct 22 '19 18:10 spencergibb