marcosbarbero / spring-cloud-zuul-ratelimit

Rate limit auto-configure for Spring Cloud Netflix Zuul
https://blog.marcosbarbero.com/spring-cloud-netflix-zuul-rate-limit/
Apache License 2.0
1.14k stars 387 forks source link

RestApi not working with spring cloud zuul+ratelimit #167

Closed Priyanka-khadke closed 5 years ago

Priyanka-khadke commented 5 years ago

i was trying to use your library to add ratelimit feature to the rest api's.I am using the type as origin and the repository type as JPA. I'm using mysql as my database and have configured the same in properties file. My application runs without any issue but when i try to send the http request to my endpoint using postman client,it gives error response as this: { "timestamp": 1562646339330, "status": 500, "error": "Internal Server Error", "exception": "com.netflix.zuul.exception.ZuulException", "message": "pre:RateLimitPreFilter" } in the console i get this error: Caused by: java.lang.NoSuchMethodError: com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.repository.springdata.RateLimiterRepository.findById(Ljava/lang/Object;)Ljava/util/Optional;

Changes made:

Added the zuul(1.4.7.RELEASE) +ratelimit(2.2.0.RELEASE) and the spring data jpa(1.5.20.RELEASE) dependency added application.yml file with basic zuul properties. Database configuration in application properties file . Controller class with some endpoints SpringBoot Application startup class In the database i can see that a table with the name 'rate' is created but the table is empty.

Can you please tell me what is the issue ,or am i missing any configuration.

Priyanka-khadke commented 5 years ago

It tries to get the rate entity based on key from mysql,and at the library class JpaRateLimiter.getRate(JpaRateLimiter.java:43) it throws NoSuchMethodError

marcosbarbero commented 5 years ago

Hi @Priyanka-khadke I'm sorry for the delay, the problem you are facing is related to the versions, if you are using spring boot on 1.x.x line you should use the rate limit on 1.7.x line instead of 2.x.x

Priyanka-khadke commented 5 years ago

Thank you so much marco,it worked:)

Priyanka-khadke commented 5 years ago

Hi Marcos, One small query ,i just browsed through some of the comments /suggestions given for your rate limit library, and i got to know that someone has suggested to include a new type , i.e by clientId of oauth2 token and i wanted to know if the feature is implemented in your library?If not by when can we expect? I wanted to this feature in my application, so just wanted to know about the status. It would be of great help if this feature is included in your library.

marcosbarbero commented 5 years ago

Hi @Priyanka-khadke I started to work on it but I didn't have time to finish it just yet, there's a branch with some WIP here in this repo.

Priyanka-khadke commented 5 years ago

Ok thanks for the information :)