I working spring batch project, to read records from the DB then write to rabbitmq, then send to HTTP message gateway. The gateway has 150TPS and I need to limit my application to 150TPS. Is there a way to throttle with spring batch or any other better way?
You can do it:
ItemWriteListener#beforeWrite
, delay the writing of items using Thread.sleep
or using a rate limiting library like Guava or Resilience4j Hope this helps.
You can try it with chunk oriented processing by defining the maximum chunk size to your TPS or less than that.
You can refer to the below doc for implementing Spring batch by Chunk Oriented Processing:
https://docs.spring.io/spring-batch/trunk/reference/html/configureStep.html
Hope it helps...
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.