简体   繁体   English

Spring 重试 - 线程中断处理

[英]Spring retry - Thread interruption handling

I am using spring-retry v1.3.1 with @Retryable annotation and I have a few questions on its behaviour.我正在使用带有 @Retryable 注释的 spring-retry v1.3.1,我对其行为有一些疑问。 Let's say that in my spring boot application I have a retry configuration that makes my application wait 1 hour before retrying.假设在我的 spring 启动应用程序中,我有一个重试配置,使我的应用程序在重试前等待 1 小时。 If my application is killed (for example by kubernetes) while it was waiting in order to do a retry is there a way to catch it and do some operations before shutting down (logging for example)?如果我的应用程序在等待重试时被杀死(例如被 kubernetes),是否有办法在关闭之前捕获它并执行一些操作(例如记录)? Also I'm not sure how spring-retry is using threads, if I end up with many retry attempts is there a risk that it blocks the application because of too many threads?另外我不确定spring-retry是如何使用线程的,如果我最终进行了多次重试尝试,是否存在由于线程过多而阻塞应用程序的风险? Is there a way to give a dedicate thread pool to retryable?有没有办法给一个专用的线程池重试?

When interrupted, a BackOffInterruptedException is thrown to the caller so you can catch that.中断时,会向调用者抛出BackOffInterruptedException ,以便您可以捕获它。

spring-retry itself does not manage threads; spring-retry本身不管理线程; that's up to you.这取决于你。

It is completely thread-based so, yes, you can end up with many suspended threads unless you manage the work with, for example, a ThreadPoolTaskExecutor .它是完全基于线程的,所以,是的,除非您使用例如ThreadPoolTaskExecutor来管理工作,否则您最终会得到许多挂起的线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM