简体   繁体   中英

How to implement the Redis Rate Limiting in spring cloud gateway?

I am trying to set up the rate-limiting in a spring cloud gateway.

I tried to configure the filter in the application.yaml as below

filters:
    - name: RequestRateLimiter
      args:
         redis-rate-limiter.replenishRate: 1
         redis-rate-limiter.burstCapacity: 5

I am getting the below error

java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name RequestRateLimiter

How to implement the rate limit in the spring cloud gateway?

One of the possibilities is not including the following dependency (the mistake which I did first time)

org.springframework.boot:spring-boot-starter-data-redis-reactive

Since the args contain redis-rate-limiter this dependency is must.

Below is a screenshot from the IDE showing RequestRateLimiterGatewayFilterFactory getting added when the above dependency is included.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM