20
20
import java .time .Instant ;
21
21
import java .util .concurrent .Executor ;
22
22
import java .util .concurrent .ScheduledFuture ;
23
- import java .util .concurrent .ThreadPoolExecutor ;
24
23
import java .util .concurrent .TimeUnit ;
25
24
26
25
import org .apache .commons .logging .Log ;
27
26
import org .apache .commons .logging .LogFactory ;
28
27
28
+ import org .springframework .core .task .TaskExecutor ;
29
29
import org .springframework .lang .Nullable ;
30
30
import org .springframework .messaging .simp .stomp .StompBrokerRelayMessageHandler ;
31
31
import org .springframework .scheduling .TaskScheduler ;
@@ -66,10 +66,10 @@ public class WebSocketMessageBrokerStats {
66
66
private StompBrokerRelayMessageHandler stompBrokerRelay ;
67
67
68
68
@ Nullable
69
- private ThreadPoolExecutor inboundChannelExecutor ;
69
+ private TaskExecutor inboundChannelExecutor ;
70
70
71
71
@ Nullable
72
- private ThreadPoolExecutor outboundChannelExecutor ;
72
+ private TaskExecutor outboundChannelExecutor ;
73
73
74
74
@ Nullable
75
75
private TaskScheduler sockJsTaskScheduler ;
@@ -106,12 +106,12 @@ public void setStompBrokerRelay(StompBrokerRelayMessageHandler stompBrokerRelay)
106
106
this .stompBrokerRelay = stompBrokerRelay ;
107
107
}
108
108
109
- public void setInboundChannelExecutor (ThreadPoolTaskExecutor inboundChannelExecutor ) {
110
- this .inboundChannelExecutor = inboundChannelExecutor . getThreadPoolExecutor () ;
109
+ public void setInboundChannelExecutor (TaskExecutor inboundChannelExecutor ) {
110
+ this .inboundChannelExecutor = inboundChannelExecutor ;
111
111
}
112
112
113
- public void setOutboundChannelExecutor (ThreadPoolTaskExecutor outboundChannelExecutor ) {
114
- this .outboundChannelExecutor = outboundChannelExecutor . getThreadPoolExecutor () ;
113
+ public void setOutboundChannelExecutor (TaskExecutor outboundChannelExecutor ) {
114
+ this .outboundChannelExecutor = outboundChannelExecutor ;
115
115
}
116
116
117
117
public void setSockJsTaskScheduler (TaskScheduler sockJsTaskScheduler ) {
@@ -174,14 +174,16 @@ public String getStompBrokerRelayStatsInfo() {
174
174
* Get stats about the executor processing incoming messages from WebSocket clients.
175
175
*/
176
176
public String getClientInboundExecutorStatsInfo () {
177
- return (this .inboundChannelExecutor != null ? getExecutorStatsInfo (this .inboundChannelExecutor ) : "null" );
177
+ return (this .inboundChannelExecutor != null ?
178
+ getExecutorStatsInfo (this .inboundChannelExecutor ) : "null" );
178
179
}
179
180
180
181
/**
181
182
* Get stats about the executor processing outgoing messages to WebSocket clients.
182
183
*/
183
184
public String getClientOutboundExecutorStatsInfo () {
184
- return (this .outboundChannelExecutor != null ? getExecutorStatsInfo (this .outboundChannelExecutor ) : "null" );
185
+ return (this .outboundChannelExecutor != null ?
186
+ getExecutorStatsInfo (this .outboundChannelExecutor ) : "null" );
185
187
}
186
188
187
189
/**
@@ -201,6 +203,8 @@ public String getSockJsTaskSchedulerStatsInfo() {
201
203
}
202
204
203
205
private String getExecutorStatsInfo (Executor executor ) {
206
+ executor = executor instanceof ThreadPoolTaskExecutor ?
207
+ ((ThreadPoolTaskExecutor ) executor ).getThreadPoolExecutor () : executor ;
204
208
String str = executor .toString ();
205
209
return str .substring (str .indexOf ("pool" ), str .length () - 1 );
206
210
}
0 commit comments