Skip to content

Commit 5c17f9a

Browse files
committed
Remove consumer executor service
It was used for consumer polling loops, but consumers do not work this way anymore. The method to set it in the environment builder has been deprecated and is now a no-op. References #93
1 parent 506e191 commit 5c17f9a

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

src/main/java/com/rabbitmq/client/amqp/impl/AmqpEnvironment.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ class AmqpEnvironment implements Environment {
3737
private final AtomicBoolean closed = new AtomicBoolean(false);
3838
private final boolean internalExecutor;
3939
private final boolean internalScheduledExecutor;
40-
private final boolean internalConsumerExecutor;
4140
private final boolean internalPublisherExecutor;
4241
private final ExecutorService executorService;
4342
private final ScheduledExecutorService scheduledExecutorService;
4443
private final ExecutorService publisherExecutorService;
45-
private final ExecutorService consumerExecutorService;
4644
private final ConnectionManager connectionManager = new ConnectionManager(this);
4745
private final long id;
4846
private final Clock clock = new Clock();
@@ -58,7 +56,6 @@ class AmqpEnvironment implements Environment {
5856
ExecutorService executorService,
5957
ScheduledExecutorService scheduledExecutorService,
6058
ExecutorService publisherExecutorService,
61-
ExecutorService consumerExecutorService,
6259
DefaultConnectionSettings<?> connectionSettings,
6360
MetricsCollector metricsCollector,
6461
ObservationCollector observationCollector) {
@@ -91,14 +88,6 @@ class AmqpEnvironment implements Environment {
9188
this.publisherExecutorService = publisherExecutorService;
9289
this.internalPublisherExecutor = false;
9390
}
94-
if (consumerExecutorService == null) {
95-
this.consumerExecutorService =
96-
Executors.newCachedThreadPool(Utils.threadFactory(threadPrefix + "consumer-"));
97-
this.internalConsumerExecutor = true;
98-
} else {
99-
this.consumerExecutorService = consumerExecutorService;
100-
this.internalConsumerExecutor = false;
101-
}
10291
this.metricsCollector =
10392
metricsCollector == null ? NoOpMetricsCollector.INSTANCE : metricsCollector;
10493
this.observationCollector =
@@ -147,9 +136,6 @@ public void close() {
147136
if (this.internalPublisherExecutor) {
148137
this.publisherExecutorService.shutdownNow();
149138
}
150-
if (this.internalConsumerExecutor) {
151-
this.consumerExecutorService.shutdownNow();
152-
}
153139
if (this.clockRefreshFuture != null) {
154140
this.clockRefreshFuture.cancel(false);
155141
}
@@ -170,10 +156,6 @@ ExecutorService publisherExecutorService() {
170156
return this.publisherExecutorService;
171157
}
172158

173-
ExecutorService consumerExecutorService() {
174-
return this.consumerExecutorService;
175-
}
176-
177159
ScheduledExecutorService scheduledExecutorService() {
178160
return this.scheduledExecutorService;
179161
}

src/main/java/com/rabbitmq/client/amqp/impl/AmqpEnvironmentBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class AmqpEnvironmentBuilder implements EnvironmentBuilder {
3535
private ExecutorService executorService;
3636
private ScheduledExecutorService scheduledExecutorService;
3737
private ExecutorService publisherExecutorService;
38-
private ExecutorService consumerExecutorService;
3938
private MetricsCollector metricsCollector = NoOpMetricsCollector.INSTANCE;
4039
private ObservationCollector observationCollector = Utils.NO_OP_OBSERVATION_COLLECTOR;
4140

@@ -82,15 +81,18 @@ public AmqpEnvironmentBuilder publisherExecutorService(ExecutorService publisher
8281
}
8382

8483
/**
85-
* Set executor service used for consumer loops.
84+
* Deprecated, do not use anymore. Consumers do not use a polling loop anymore.
85+
*
86+
* <p>Set executor service used for consumer loops.
8687
*
8788
* <p>The library uses sensible defaults, override only in case of problems.
8889
*
8990
* @param consumerExecutorService the executor service
9091
* @return this builder instance
92+
* @deprecated Do not use anymore
9193
*/
94+
@Deprecated(forRemoval = true)
9295
public AmqpEnvironmentBuilder consumerExecutorService(ExecutorService consumerExecutorService) {
93-
this.consumerExecutorService = consumerExecutorService;
9496
return this;
9597
}
9698

@@ -144,7 +146,6 @@ public Environment build() {
144146
executorService,
145147
scheduledExecutorService,
146148
publisherExecutorService,
147-
consumerExecutorService,
148149
connectionSettings,
149150
metricsCollector,
150151
observationCollector);

src/test/java/com/rabbitmq/client/amqp/impl/AmqpConnectionRecoveryTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static void initAll() {
5959
null,
6060
null,
6161
null,
62-
null,
6362
connectionSettings,
6463
NoOpMetricsCollector.INSTANCE,
6564
Utils.NO_OP_OBSERVATION_COLLECTOR);

0 commit comments

Comments
 (0)