Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Arranque de resorte (.2.3.0.RELEASE) con límite de velocidad de bucket4j que no funciona

Estoy tratando de usar la API de tasa de límite para una aplicación Spring Boot Rest, con bucket4j basado en el siguiente recurso en línea

Encuentre mi configuración a continuación:

A continuación se agrega la dependencia maven para usar 4bucketj:

 ... <dependency> <groupId>com.giffing.bucket4j.spring.boot.starter</groupId> <artifactId>bucket4j-spring-boot-starter</artifactId> <version>0.4.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> </dependency> ..

A continuación se muestra mi configuración application.yml:

 spring: main: allow-bean-definition-overriding: true cache: jcache: config: classpath:ehcache.xml bucket4j: enabled: true filters: - cache-name: buckets url: .* http-response-body: "{ \"status\": 429, \"error\": \"Too Many Requests\", \"message\": \"You have exhausted your API Request Quota\" }" rate-limits: - bandwidths: - capacity: 2 time: 1 unit: minutes

A continuación, he agregado ehcache.xml en la ruta src/main/resources/:

 <config xmlns='http://www.ehcache.org/v3' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jsr107="http://www.ehcache.org/v3/jsr107" xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd"> <cache alias="buckets"> <expiry> <ttl unit="seconds">3600</ttl> </expiry> <heap unit="entries">1000000</heap> <jsr107:mbeans enable-statistics="true"/> </cache>

Finalmente, agregué @EnableCaching en una clase de configuración que se carga cuando comienza la primavera.

Según la configuración del archivo application.yml, la API no debería aceptar más de 2 solicitudes en un minuto y, si son más de dos solicitudes, se debería activar un error como se indica ( http-response-body ) en application.yml.

Implementé la aplicación en mi PC y con la herramienta Postman puedo presionar una API Rest más de 10 veces en un minuto sin ningún mensaje de error.

¿Alguien puede indicar por qué no se activa el mensaje de error, ya que debería permitir solo 2 solicitudes y estoy enviando 10 en su lugar?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!