我在春季批处理项目中工作,从DB中读取记录,然后写入Rabbitmq,然后发送至HTTP消息网关。网关具有 150TPS ,我需要将应用程序限制为150TPS。有什么方法可以节气弹簧或其他更好的方法?
答案 0 :(得分:3)
您可以做到:
ItemWriteListener#beforeWrite
,使用Thread.sleep
或使用速率限制库(例如Guava或Resilience4j 希望这会有所帮助。
答案 1 :(得分:0)
您可以通过将最大块大小定义为TPS或小于TPS的最大块大小来尝试面向块的处理。
您可以参考以下文档,了解如何通过Chunk Oriented Processing实现Spring批处理:
https://docs.spring.io/spring-batch/trunk/reference/html/configureStep.html
希望有帮助...