Skip to content

Commit dc6b3ba

Browse files
author
Domonkos Gulyas
committed
Resolve TaskExecutor bean conflict
Spring Boot 3 resolves TaskExecutor beans more strictly. Explicit bean naming avoids ambiguity with TaskScheduler.
1 parent aa26c17 commit dc6b3ba

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/java/org/phoebus/channelfinder/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public List<ChannelProcessor> channelProcessors() {
119119
*
120120
* @return A {@link TaskExecutor}
121121
*/
122-
@Bean
122+
@Bean("channelFinderTaskExecutor")
123123
public TaskExecutor taskExecutor() {
124124
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
125125
taskExecutor.setCorePoolSize(3);

src/main/java/org/phoebus/channelfinder/service/ChannelProcessorService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.phoebus.channelfinder.entity.Channel;
1313
import org.phoebus.channelfinder.service.model.archiver.ChannelProcessorInfo;
1414
import org.springframework.beans.factory.annotation.Autowired;
15+
import org.springframework.beans.factory.annotation.Qualifier;
1516
import org.springframework.beans.factory.annotation.Value;
1617
import org.springframework.core.task.TaskExecutor;
1718
import org.springframework.stereotype.Service;
@@ -23,16 +24,16 @@ public class ChannelProcessorService {
2324

2425
private final List<ChannelProcessor> channelProcessors;
2526

26-
private final TaskExecutor taskExecutor;
27+
private final TaskExecutor channelFinderTaskExecutor;
2728

2829
private final int chunkSize;
2930

3031
public ChannelProcessorService(
3132
@Autowired List<ChannelProcessor> channelProcessors,
32-
@Autowired TaskExecutor taskExecutor,
33+
@Autowired @Qualifier("channelFinderTaskExecutor") TaskExecutor channelFinderTaskExecutor,
3334
@Value("${processors.chunking.size:10000}") int chunkSize) {
3435
this.channelProcessors = channelProcessors;
35-
this.taskExecutor = taskExecutor;
36+
this.channelFinderTaskExecutor = channelFinderTaskExecutor;
3637
this.chunkSize = chunkSize;
3738
}
3839

@@ -66,7 +67,7 @@ public void sendToProcessors(List<Channel> channels) {
6667
if (channelProcessors.isEmpty()) {
6768
return;
6869
}
69-
taskExecutor.execute(
70+
channelFinderTaskExecutor.execute(
7071
() ->
7172
channelProcessors.stream()
7273
.filter(ChannelProcessor::enabled)

0 commit comments

Comments
 (0)