Is this possible or is it managed by the Application Server? Passing the ThreadPoolTaskExecutor ref to a bean is a no-brainer but trying to set the threadfactory on the aforementioned executor seems to have no effect ...
Actually, setting a ThreadFactory
is a no-brainer as well:
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="threadFactory" ref="threadFactory"/>
</bean>
<bean id="threadFactory" class="org.springframework.scheduling.concurrent.CustomizableThreadFactory">
<constructor-arg value="Custom-prefix-"/>
</bean>
or:
@Bean
public ThreadPoolTaskExecutor taskExecutor() {
final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadFactory(threadFactory());
return taskExecutor;
}
@Bean
public ThreadFactory threadFactory() {
return new CustomizableThreadFactory("Custom-prefix-");
}
Note that ThreadPoolTaskExecutor
extends from ExecutorConfigurationSupport
and this is where setThreadFactory(java.util.concurrent.ThreadFactory)
is defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With