alibaba / alibaba-rsocket-broker

Alibaba RSocket Broker: Mesh, Streaming & IoT

Home Page:https://alibroker.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In the yaml, if rsocket.brokers is list, `RSocketBrokerHealthIndicator` is not registered.

amondnet opened this issue · comments

Describe the bug

In the yaml, if rsocket.brokers is a list, then RSocketBrokerHealthIndicator is not registered.

    rsocket:
      brokers: 
      - tcp://localhost:9999

If it is a string, then RSocketBrokerHealthIndicator is registered.

    rsocket:
      brokers: tcp://localhost:9999

Environment

  • Alibaba RSocket Broker version: 1.1.5
  • Operating System version: Mac
  • Java version: 17

Steps to reproduce this issue

  1. set rsocket.brokers to list
    rsocket:
      brokers: 
      - tcp://localhost:9999
    management:
      endpoint:
        health:
          show-details: always      
  2. bootRun
  3. open http://localhost:8080/actuator/health

Pls. provide GitHub address to reproduce this issue.

Expected Result

{
  "status": "DOWN",
  "components": {
   "mongo": {
      "status": "UP",
      "details": {
        "maxWireVersion": 17
      }
    },
    "ping": {
      "status": "UP"
    },
    "r2dbc": {
      "status": "UP",
      "details": {
        "database": "MariaDB",
        "validationQuery": "validate(REMOTE)"
      }
    },
    "rsocketBrokerHealth": {
      "status": "DOWN",
      "details": {
        "brokers": "tcp://localhost:9999"
      }
    }
  }
}

Actual Result

{
  "status": "UP",
  "components": {
    "mongo": {
      "status": "UP",
      "details": {
        "maxWireVersion": 17
      }
    },
    "ping": {
      "status": "UP"
    },
    "r2dbc": {
      "status": "UP",
      "details": {
        "database": "MariaDB",
        "validationQuery": "validate(REMOTE)"
      }
    }
  }
}

rsocket.broker.topology=gossip
rsocket.broker.seeds=192.168.1.2,192.168.1.3,192.168.1.4

@shareisall

rsocket.broker.topology=gossip
rsocket.broker.seeds=192.168.1.2,192.168.1.3,192.168.1.4

The above properties are used by the alibaba-rsocket-server. This issue occurs in alibaba-rsocket-spring-boot-starter..

    @Bean
    @ConditionalOnProperty("rsocket.brokers")
    public RSocketBrokerHealthIndicator rsocketBrokerHealth(RSocketEndpoint rsocketEndpoint, UpstreamManager upstreamManager, @Value("${rsocket.brokers}") String brokers) {
        return new RSocketBrokerHealthIndicator(rsocketEndpoint, upstreamManager, brokers);
    }

If you use application.properties or application.yaml + string, the RSocketBrokerHealthIndicator will be registered without any problems.

rsocket.brokers=tcp://localhost:9999
rsocket:
  brokers: tcp://localhost:9999

However, if you use an array of strings, it won't register.

rsocket:
  brokers:
  - tcp://localhost:9999

This is fine for practical use, but kubernetes scheduler can't perform health checks properly because the health indicator is not registered.

Sorry for last reply. But it works for me.

Envirements:

  • SpringBoot 3.1.4
  • Alibaba RSocket Broker version: 1.1.5
  • Operating System version: Mac
  • Java version: 17

Code:

rsocket:
  brokers:
    - tcp://127.0.0.1:9999
    - tcp://127.0.0.1:9999
  jwt-token: None

Array indentation should be 2 space in your yaml file.

@shareisall

I've been using alibaba-rsocket-broker in production for over a year. I'm not talking about the rsocket app not working, I'm talking about the health indicator not registering.

https://github.com/alibaba/alibaba-rsocket-broker/blob/master/alibaba-rsocket-spring-boot-starter/src/main/java/com/alibaba/spring/boot/rsocket/RSocketBrokerHealthIndicator.java

public RSocketBrokerHealthIndicator rsocketBrokerHealth(RSocketEndpoint rsocketEndpoint, UpstreamManager upstreamManager, @Value("${rsocket.brokers}") String brokers) {

In the yaml, if rsocket.brokers is a list, then RSocketBrokerHealthIndicator is not registered.

  1. use string
rsocket:
  brokers: tcp://127.0.0.1:9999
  jwt-token: None
management:
  endpoint:
    health:
      show-details: always
curl http://localhost:8080/actuator/health/rsocketBrokerHealth
{"status":"UP","details":{"brokers":"tcp://127.0.0.1:9999","localServiceStatus":"Serving"}}
  1. use array
rsocket:
  brokers: 
    - tcp://127.0.0.1:9999
  jwt-token: None
management:
  endpoint:
    health:
      show-details: always
curl http://localhost:8080/actuator/health/rsocketBrokerHealth

-->

You are right, there's a bug in the method rsocketBrokerHealth of class com.alibaba.spring.boot.rsocket.RSocketAutoConfiguration.

CODE:

@Bean
@ConditionalOnProperty("rsocket.brokers")
public RSocketBrokerHealthIndicator rsocketBrokerHealth(
    RSocketEndpoint rsocketEndpoint,
    UpstreamManager upstreamManager,
    @Value("${rsocket.brokers}") String brokers
) {
        return new RSocketBrokerHealthIndicator(rsocketEndpoint, upstreamManager, brokers);
}