spring-attic / spring-cloud-rsocket

This repository is now inactive. Please see https://github.com/rsocket-routing/
https://github.com/rsocket-routing/
Apache License 2.0
49 stars 13 forks source link

Document forwarding metadata with dots in keys #4

Open FWinkler79 opened 4 years ago

FWinkler79 commented 4 years ago

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.

spencergibb commented 4 years ago

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