@@ -66,6 +66,7 @@ class StreamEnvironment implements Environment {
66
66
67
67
private final EventLoopGroup eventLoopGroup ;
68
68
private final ScheduledExecutorService scheduledExecutorService ;
69
+ private final ScheduledExecutorService locatorReconnectionScheduledExecutorService ;
69
70
private final boolean privateScheduleExecutorService ;
70
71
private final Client .ClientParameters clientParametersPrototype ;
71
72
private final List <Address > addresses ;
@@ -235,17 +236,22 @@ class StreamEnvironment implements Environment {
235
236
maxProducersByConnection ,
236
237
maxTrackingConsumersByConnection ,
237
238
connectionNamingStrategy ,
238
- Utils . coordinatorClientFactory (this , producerNodeRetryDelay ),
239
+ coordinatorClientFactory (this , producerNodeRetryDelay ),
239
240
forceLeaderForProducers );
240
241
this .consumersCoordinator =
241
242
new ConsumersCoordinator (
242
243
this ,
243
244
maxConsumersByConnection ,
244
245
connectionNamingStrategy ,
245
- Utils . coordinatorClientFactory (this , consumerNodeRetryDelay ),
246
+ coordinatorClientFactory (this , consumerNodeRetryDelay ),
246
247
forceReplicaForConsumers ,
247
248
Utils .brokerPicker ());
248
249
this .offsetTrackingCoordinator = new OffsetTrackingCoordinator (this );
250
+
251
+ ThreadFactory threadFactory = threadFactory ("rabbitmq-stream-environment-locator-scheduler-" );
252
+ this .locatorReconnectionScheduledExecutorService =
253
+ Executors .newScheduledThreadPool (this .locators .size (), threadFactory );
254
+
249
255
ClientParameters clientParametersForInit = locatorParametersCopy ();
250
256
Runnable locatorInitSequence =
251
257
() -> {
@@ -291,7 +297,7 @@ class StreamEnvironment implements Environment {
291
297
l ,
292
298
connectionNamingStrategy ,
293
299
clientFactory ,
294
- this .scheduledExecutorService ,
300
+ this .locatorReconnectionScheduledExecutorService ,
295
301
this .recoveryBackOffDelayPolicy ,
296
302
l .label ());
297
303
}
@@ -338,7 +344,7 @@ private ShutdownListener shutdownListener(
338
344
locator ,
339
345
connectionNamingStrategy ,
340
346
clientFactory ,
341
- this .scheduledExecutorService ,
347
+ this .locatorReconnectionScheduledExecutorService ,
342
348
delayPolicy ,
343
349
label );
344
350
} else {
@@ -683,6 +689,9 @@ public void close() {
683
689
if (privateScheduleExecutorService ) {
684
690
this .scheduledExecutorService .shutdownNow ();
685
691
}
692
+ if (this .locatorReconnectionScheduledExecutorService != null ) {
693
+ this .locatorReconnectionScheduledExecutorService .shutdownNow ();
694
+ }
686
695
try {
687
696
if (this .eventLoopGroup != null
688
697
&& (!this .eventLoopGroup .isShuttingDown () || !this .eventLoopGroup .isShutdown ())) {
@@ -904,13 +913,7 @@ TrackingConsumerRegistration registerTrackingConsumer(
904
913
@ Override
905
914
public String toString () {
906
915
return "{ \" locators\" : ["
907
- + this .locators .stream ()
908
- .map (
909
- l -> {
910
- Client c = l .nullableClient ();
911
- return c == null ? "null" : ("\" " + l .label () + "\" " );
912
- })
913
- .collect (Collectors .joining ("," ))
916
+ + this .locators .stream ().map (l -> quote (l .label ())).collect (Collectors .joining ("," ))
914
917
+ "], "
915
918
+ Utils .jsonField ("producer_client_count" , this .producersCoordinator .clientCount ())
916
919
+ ","
0 commit comments