1. Overview
1.1 Plugin Name
- SpringCloud Plugin
1.2 Appropriate Scenario
- transform http to springcloud
- springcloud gray flow control
1.3 Plugin functionality
- transform http protocol into springCloud protocol.
1.4 Plugin code
-
Core Module
shenyu-plugin-springcloud -
Core Class
org.apache.shenyu.plugin.springcloud.SpringCloudPlugin
1.5 Added Since Which shenyu version
Since ShenYu 2.4.0
2. How to use plugin
-
Add related dependencies and enable plugin, please refer to: Quick start with Spring Cloud .
-
Spring Cloudclient access, please refer to: Spring Cloud Proxy .
2.1 Plugin-use procedure chart

2.2 Import pom
- Eureka Registry
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-springcloud</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>${eureka-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>${spring-cloud-commons.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-httpclient</artifactId>
<version>${project.version}</version>
</dependency>
- Nacos Registry
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-springcloud</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${nacos-discovery.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>${spring-cloud-commons.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-httpclient</artifactId>
<version>${project.version}</version>
</dependency>
2.3 Config SpringCloud in ShenYu-Boostrap
2.3.1 Config SpringCloud Registry With Eureka
spring:
cloud:
discovery:
enabled: true
eureka:
client:
enabled: true
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
prefer-ip-address: true
2.3.2 Config SpringCloud Registry With Nacos
spring:
cloud:
discovery:
enabled: true
nacos:
discovery:
server-addr: 127.0.0.1:8848 # Spring Cloud Alibaba Dubbo use this.
enabled: true
namespace: ShenyuRegisterCenter
2.3.3 Config SpringCloud LoadBalancer
Notice
After ShenYu 2.5.0(include), ShenYu use
shenyu-loadbalanceras loadbalancer client, you just config loadbalance in springcloud plugin rule. if you don't config loadbalance, springcloud plugin will useroundRobinalgorithm.Before ShenYu 2.4.3(include), ShenYu use
Ribbonas loadbalancer client, you must config loadbalancer as follows.
spring:
cloud:
loadbalancer:
ribbon:
enabled: true
2.4 Enable plugin
- In shenyu-admin --> BasicConfig --> Plugin -->
springCloudset Status enabled.
2.5 Config plugin
2.5.1 Plugin config
- you must config springcloud registry and set springcloud plugin enabled.
2.5.2 Selector And Gray Config

- Gray routing
if you want to user gray route in springCloud-plugin, you can click the gray button.

- Gray level publishing can customize and control the traffic proportion of new version applications when publishing new version applications, gradually complete the full launch of new version applications, maximize the business risk caused by new version publishing, reduce the impact surface caused by faults, and support rapid roll back.
when the gray is open,Gateway load balancing will select one node from the current node list for routing and you can modify node weights to change the weight of nodes in the load balancing algorithm.
It should be noted that,if your business instance not use the client jar of shenyu-client-springcloud, You should add gray node information manually on this selector page.
-
serviceId: your springcloud service id -
gray:enable gray routing.-
protocol: protocol default is 'http://'. -
upstreamUrl: the server instance host, ip:port. -
weight: the server instance and participate in load balancing calculation. -
status: true: the server is available,false: the server is unavailable. -
timestamp: the server's start time. -
warmup: the server's warm up time and and participate in load balancing calculation.
-
2.5.3 Rule Config
Rule Handler, the handle field, can be performed by the gateway after the final matching of traffic. For more information, please refer to Plugin handle management in Plugin Config.
- use
shenyu-client-springcloudrule config

-
details:
timeout:set time out.loadbalance:loadbalance algorithm,there are three options:roundRobin,random,hash
-
not use
shenyu-client-springcloudrule config

-
details:
path:request path.timeout:set time out.