21
21
import java .util .HashMap ;
22
22
import java .util .List ;
23
23
import java .util .Map ;
24
+ import java .util .concurrent .Executor ;
24
25
import java .util .function .Supplier ;
25
26
26
27
import org .springframework .beans .factory .BeanInitializationException ;
30
31
import org .springframework .context .SmartLifecycle ;
31
32
import org .springframework .context .annotation .Bean ;
32
33
import org .springframework .context .event .SmartApplicationListener ;
33
- import org .springframework .core .task .TaskExecutor ;
34
34
import org .springframework .lang .Nullable ;
35
35
import org .springframework .messaging .MessageHandler ;
36
36
import org .springframework .messaging .converter .ByteArrayMessageConverter ;
@@ -158,7 +158,7 @@ public ApplicationContext getApplicationContext() {
158
158
159
159
@ Bean
160
160
public AbstractSubscribableChannel clientInboundChannel (
161
- @ Qualifier ("clientInboundChannelExecutor" ) TaskExecutor executor ) {
161
+ @ Qualifier ("clientInboundChannelExecutor" ) Executor executor ) {
162
162
163
163
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel (executor );
164
164
channel .setLogger (SimpLogging .forLog (channel .getLogger ()));
@@ -170,9 +170,9 @@ public AbstractSubscribableChannel clientInboundChannel(
170
170
}
171
171
172
172
@ Bean
173
- public TaskExecutor clientInboundChannelExecutor () {
173
+ public Executor clientInboundChannelExecutor () {
174
174
ChannelRegistration registration = getClientInboundChannelRegistration ();
175
- TaskExecutor executor = getTaskExecutor (registration , "clientInboundChannel-" , this ::defaultTaskExecutor );
175
+ Executor executor = getExecutor (registration , "clientInboundChannel-" , this ::defaultExecutor );
176
176
if (executor instanceof ExecutorConfigurationSupport executorSupport ) {
177
177
executorSupport .setPhase (getPhase ());
178
178
}
@@ -209,7 +209,7 @@ protected void configureClientInboundChannel(ChannelRegistration registration) {
209
209
210
210
@ Bean
211
211
public AbstractSubscribableChannel clientOutboundChannel (
212
- @ Qualifier ("clientOutboundChannelExecutor" ) TaskExecutor executor ) {
212
+ @ Qualifier ("clientOutboundChannelExecutor" ) Executor executor ) {
213
213
214
214
ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel (executor );
215
215
channel .setLogger (SimpLogging .forLog (channel .getLogger ()));
@@ -221,9 +221,9 @@ public AbstractSubscribableChannel clientOutboundChannel(
221
221
}
222
222
223
223
@ Bean
224
- public TaskExecutor clientOutboundChannelExecutor () {
224
+ public Executor clientOutboundChannelExecutor () {
225
225
ChannelRegistration registration = getClientOutboundChannelRegistration ();
226
- TaskExecutor executor = getTaskExecutor (registration , "clientOutboundChannel-" , this ::defaultTaskExecutor );
226
+ Executor executor = getExecutor (registration , "clientOutboundChannel-" , this ::defaultExecutor );
227
227
if (executor instanceof ExecutorConfigurationSupport executorSupport ) {
228
228
executorSupport .setPhase (getPhase ());
229
229
}
@@ -250,11 +250,11 @@ protected void configureClientOutboundChannel(ChannelRegistration registration)
250
250
@ Bean
251
251
public AbstractSubscribableChannel brokerChannel (
252
252
AbstractSubscribableChannel clientInboundChannel , AbstractSubscribableChannel clientOutboundChannel ,
253
- @ Qualifier ("brokerChannelExecutor" ) TaskExecutor executor ) {
253
+ @ Qualifier ("brokerChannelExecutor" ) Executor executor ) {
254
254
255
255
MessageBrokerRegistry registry = getBrokerRegistry (clientInboundChannel , clientOutboundChannel );
256
256
ChannelRegistration registration = registry .getBrokerChannelRegistration ();
257
- ExecutorSubscribableChannel channel = (registration .hasTaskExecutor () ?
257
+ ExecutorSubscribableChannel channel = (registration .hasExecutor () ?
258
258
new ExecutorSubscribableChannel (executor ) : new ExecutorSubscribableChannel ());
259
259
registration .interceptors (new ImmutableMessageChannelInterceptor ());
260
260
channel .setLogger (SimpLogging .forLog (channel .getLogger ()));
@@ -263,38 +263,38 @@ public AbstractSubscribableChannel brokerChannel(
263
263
}
264
264
265
265
@ Bean
266
- public TaskExecutor brokerChannelExecutor (
266
+ public Executor brokerChannelExecutor (
267
267
AbstractSubscribableChannel clientInboundChannel , AbstractSubscribableChannel clientOutboundChannel ) {
268
268
269
269
MessageBrokerRegistry registry = getBrokerRegistry (clientInboundChannel , clientOutboundChannel );
270
270
ChannelRegistration registration = registry .getBrokerChannelRegistration ();
271
- TaskExecutor executor = getTaskExecutor (registration , "brokerChannel-" , () -> {
271
+ Executor executor = getExecutor (registration , "brokerChannel-" , () -> {
272
272
// Should never be used
273
- ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor ();
274
- threadPoolTaskExecutor .setCorePoolSize (0 );
275
- threadPoolTaskExecutor .setMaxPoolSize (1 );
276
- threadPoolTaskExecutor .setQueueCapacity (0 );
277
- return threadPoolTaskExecutor ;
273
+ ThreadPoolTaskExecutor fallbackExecutor = new ThreadPoolTaskExecutor ();
274
+ fallbackExecutor .setCorePoolSize (0 );
275
+ fallbackExecutor .setMaxPoolSize (1 );
276
+ fallbackExecutor .setQueueCapacity (0 );
277
+ return fallbackExecutor ;
278
278
});
279
279
if (executor instanceof ExecutorConfigurationSupport executorSupport ) {
280
280
executorSupport .setPhase (getPhase ());
281
281
}
282
282
return executor ;
283
283
}
284
284
285
- private TaskExecutor defaultTaskExecutor () {
285
+ private Executor defaultExecutor () {
286
286
return new TaskExecutorRegistration ().getTaskExecutor ();
287
287
}
288
288
289
- private static TaskExecutor getTaskExecutor (ChannelRegistration registration ,
290
- String threadNamePrefix , Supplier <TaskExecutor > fallback ) {
289
+ private static Executor getExecutor (ChannelRegistration registration ,
290
+ String threadNamePrefix , Supplier <Executor > fallback ) {
291
291
292
- return registration .getTaskExecutor (fallback ,
292
+ return registration .getExecutor (fallback ,
293
293
executor -> setThreadNamePrefix (executor , threadNamePrefix ));
294
294
}
295
295
296
- private static void setThreadNamePrefix (TaskExecutor taskExecutor , String name ) {
297
- if (taskExecutor instanceof CustomizableThreadCreator ctc ) {
296
+ private static void setThreadNamePrefix (Executor executor , String name ) {
297
+ if (executor instanceof CustomizableThreadCreator ctc ) {
298
298
ctc .setThreadNamePrefix (name );
299
299
}
300
300
}
0 commit comments