Spring batch writer throttling

Viewed 1343

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?

2 Answers

You can do it:

  • On Spring Batch side: using a ItemWriteListener#beforeWrite, delay the writing of items using Thread.sleep or using a rate limiting library like Guava or Resilience4j
  • On RabbitMQ side: using the delayed-message-plugin to delay the delivery of messages at the desired rate.

Hope this helps.

Related