1 package de.juplo.kafka.chat.backend.implementation.kafka;
3 import lombok.extern.slf4j.Slf4j;
4 import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
5 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
9 * Customizer for the auto-configured Bean {@code applicationTaskExecutor}.
11 * This customization is necessary, because otherwise, the bean is part
12 * of the lowest phase of the {@link org.springframework.context.SmartLifecycle}
13 * and, hence, destroyed first during shutdown.
15 * Without this customization, the shutdown of the thread-pool, that is triggered
16 * this way does not succeed, blocking the furthershutdown for 30 seconds.
19 public class KafkaServicesThreadPoolTaskExecutorCustomizer implements ThreadPoolTaskExecutorCustomizer
22 public void customize(ThreadPoolTaskExecutor taskExecutor)
24 log.info("Customizing the auto-configured ThreadPoolTaskExecutor");
25 taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
26 taskExecutor.setAwaitTerminationSeconds(10);