marcosbarbero / spring-cloud-zuul-ratelimit

Rate limit auto-configure for Spring Cloud Netflix Zuul

Home Page:https://blog.marcosbarbero.com/spring-cloud-netflix-zuul-rate-limit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query regarding MatchType And breakOnMatch

CasperOm opened this issue · comments

Hi @marcosbarbero, hope you are doing good.

I was using 1.7 version of rate limit and now i have upgraded to spring boot 2.x and so the rate limit version to 2.0 but now it has started to show error "httpmethod" is not found in RateLimitProperties$Policy$MatchType: and similar error for break-on-match.

Could you please help how is it handled in latest version? and how can we rate limit for particular httpmethod and multiple limits for a service without using break-on-match.

Thanks in advance

Hi @CasperOm, the httpmethod property was deprecated long ago, you should use http_method instead.
The break-on-match property should still work though.

Hi @marcosbarbero , it showing below error for http_method


Description:

Failed to bind properties under 'zuul.ratelimit.policy-list.adminservice[0].type[2]' to com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.properties.RateLimitProperties$Policy$MatchType:

Property: zuul.ratelimit.policy-list.adminservice[0].type[2]
Value: http_method=options
Origin: class path resource [application.yml]:102:11
Reason: failed to convert java.lang.String to com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.properties.RateLimitProperties$Policy$MatchType

Action:

Update your application's configuration
}


AND for break-on-match it showing below error

Unknown property 'break-on-match' for type 'com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.config.properties.RateLimitProperties.Policy'

I see. I overlook the version you are using of this library.

So, the httpmethod is still the same in the version 2.0.0.RELEASE, and the break-on-match should work.
Can you create a public repo reproducing the issue so that I can take a look?

This is the code added in application.yml

zuul:
ratelimit:
enabled: true
behind-proxy: true
repository: JPA
policy-list:
adminService:
- limit: 1000
refresh-interval: 60
type:
- user=anonymous
- origin
- httpmethod=options
break-on-match: true
- limit: 30
refresh-interval: 60
type:
- user=anonymous
- origin
break-on-match: true


and in jar file below is the snippet for RateLimitProperties class and in this class there is no type mentioned as httpmethod
image

I'm sorry, I need an executable project to reproduce the behavior.

Hi @marcosbarbero, I have updated the code pls take latest checkout

Hi @CasperOm I still didn't have time to look into it, I'll try to take a look at your repo later today. I'll keep you posted!
Thanks for providing a working example.

Hi @marcosbarbero
Sure. Thanks !

Hi @marcosbarbero Did you get a chance to look into this?

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 1 day