|
32 | 32 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
33 | 33 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
34 | 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
| 35 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading; |
35 | 36 | import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
36 | 37 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
37 | 38 | import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
38 | 39 | import org.springframework.boot.autoconfigure.jmx.JmxProperties;
|
39 | 40 | import org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration;
|
40 | 41 | import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition;
|
41 | 42 | import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
|
| 43 | +import org.springframework.boot.autoconfigure.thread.Threading; |
42 | 44 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
43 | 45 | import org.springframework.boot.context.properties.PropertyMapper;
|
44 | 46 | import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException;
|
| 47 | +import org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder; |
45 | 48 | import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
|
46 | 49 | import org.springframework.context.annotation.Bean;
|
47 | 50 | import org.springframework.context.annotation.Conditional;
|
|
65 | 68 | import org.springframework.messaging.rsocket.RSocketStrategies;
|
66 | 69 | import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
|
67 | 70 | import org.springframework.scheduling.Trigger;
|
| 71 | +import org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler; |
68 | 72 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
69 | 73 | import org.springframework.scheduling.support.CronTrigger;
|
70 | 74 | import org.springframework.scheduling.support.PeriodicTrigger;
|
|
79 | 83 | * @author Stephane Nicoll
|
80 | 84 | * @author Vedran Pavic
|
81 | 85 | * @author Madhura Bhave
|
| 86 | + * @author Yong-Hyun Kim |
82 | 87 | * @since 1.1.0
|
83 | 88 | */
|
84 | 89 | @AutoConfiguration(after = { DataSourceAutoConfiguration.class, JmxAutoConfiguration.class,
|
@@ -169,15 +174,24 @@ private Trigger createPeriodicTrigger(Duration period, Duration initialDelay, bo
|
169 | 174 | * scheduling explicitly.
|
170 | 175 | */
|
171 | 176 | @Configuration(proxyBeanMethods = false)
|
172 |
| - @ConditionalOnBean(ThreadPoolTaskSchedulerBuilder.class) |
173 | 177 | @ConditionalOnMissingBean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
|
174 | 178 | protected static class IntegrationTaskSchedulerConfiguration {
|
175 | 179 |
|
176 | 180 | @Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
|
| 181 | + @ConditionalOnBean(ThreadPoolTaskSchedulerBuilder.class) |
| 182 | + @ConditionalOnThreading(Threading.PLATFORM) |
177 | 183 | public ThreadPoolTaskScheduler taskScheduler(ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder) {
|
178 | 184 | return threadPoolTaskSchedulerBuilder.build();
|
179 | 185 | }
|
180 | 186 |
|
| 187 | + @Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME) |
| 188 | + @ConditionalOnBean(SimpleAsyncTaskSchedulerBuilder.class) |
| 189 | + @ConditionalOnThreading(Threading.VIRTUAL) |
| 190 | + public SimpleAsyncTaskScheduler taskSchedulerVirtualThreads( |
| 191 | + SimpleAsyncTaskSchedulerBuilder simpleAsyncTaskSchedulerBuilder) { |
| 192 | + return simpleAsyncTaskSchedulerBuilder.build(); |
| 193 | + } |
| 194 | + |
181 | 195 | }
|
182 | 196 |
|
183 | 197 | /**
|
|
0 commit comments