如何加速seda关机?
How to speed up seda shutdown?
有什么方法可以停止SedaConsumer
而不用等待BlockingQueue.take(pollTimeout, ...)
到return?我的应用程序中有很多 sedas,正常关闭需要很多时间。当 DefaultShutdownStrategy
shutdown sedaConsumers
队列中不再有消息,也不会产生更多消息(因为之前实施了 routes shutdown)。所以每个sedaConsumer
都要等1秒左右
是否可以为 seda 强制执行 doStop 而不是 prepareShutdown?或者中断工作线程?
我知道我可以降低 pollTimeout
,但我担心这会影响运行时性能。
try {
// use the end user configured poll timeout
exchange = queue.poll(pollTimeout, TimeUnit.MILLISECONDS);
// Omitted
} catch (InterruptedException e) {
LOG.debug("Sleep interrupted, are we stopping? {}", isStopping() || isStopped());
continue;
} catch (Throwable e) {
if (exchange != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
} else {
getExceptionHandler().handleException(e);
}
}
此构造最多位于线程中可以抛出 InterruptedException 的位置,因此如果使用者正在停止并被中断,它将正常停止。
有什么方法可以停止SedaConsumer
而不用等待BlockingQueue.take(pollTimeout, ...)
到return?我的应用程序中有很多 sedas,正常关闭需要很多时间。当 DefaultShutdownStrategy
shutdown sedaConsumers
队列中不再有消息,也不会产生更多消息(因为之前实施了 routes shutdown)。所以每个sedaConsumer
都要等1秒左右
是否可以为 seda 强制执行 doStop 而不是 prepareShutdown?或者中断工作线程?
我知道我可以降低 pollTimeout
,但我担心这会影响运行时性能。
try {
// use the end user configured poll timeout
exchange = queue.poll(pollTimeout, TimeUnit.MILLISECONDS);
// Omitted
} catch (InterruptedException e) {
LOG.debug("Sleep interrupted, are we stopping? {}", isStopping() || isStopped());
continue;
} catch (Throwable e) {
if (exchange != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, e);
} else {
getExceptionHandler().handleException(e);
}
}
此构造最多位于线程中可以抛出 InterruptedException 的位置,因此如果使用者正在停止并被中断,它将正常停止。