Skip to content

Commit 63baa43

Browse files
Move thread factory to connection params
1 parent 058a10a commit 63baa43

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
566566
try {
567567
FrameHandler handler = fhFactory.create(addr);
568568
AMQConnection conn = new AMQConnection(params, handler);
569-
conn.setThreadFactory(this.threadFactory);
570569
conn.start();
571570
return conn;
572571
} catch (IOException e) {
@@ -580,7 +579,7 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
580579
public ConnectionParams params(ExecutorService executor) {
581580
return new ConnectionParams(username, password, executor, virtualHost, getClientProperties(),
582581
requestedFrameMax, requestedChannelMax, requestedHeartbeat, saslConfig,
583-
networkRecoveryInterval, topologyRecovery);
582+
networkRecoveryInterval, topologyRecovery, threadFactory);
584583
}
585584

586585
/**

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public AMQConnection(ConnectionParams params, FrameHandler frameHandler)
216216
this.requestedHeartbeat = params.getRequestedHeartbeat();
217217
this.saslConfig = params.getSaslConfig();
218218
this.executor = params.getExecutor();
219+
this.threadFactory = params.getThreadFactory();
219220

220221
this._channelManager = null;
221222

src/com/rabbitmq/client/impl/ConnectionParams.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.rabbitmq.client.impl;
22

33
import com.rabbitmq.client.SaslConfig;
4+
import com.rabbitmq.client.ThreadFactory;
45

56
import java.util.Map;
67
import java.util.concurrent.ExecutorService;
@@ -19,8 +20,9 @@ public class ConnectionParams {
1920
private final boolean topologyRecovery;
2021

2122
private ExceptionHandler exceptionHandler;
23+
private ThreadFactory threadFactory;
2224

23-
/**
25+
/**
2426
* @param username name used to establish connection
2527
* @param password for <code><b>username</b></code>
2628
* @param executor thread pool service for consumer threads for channels on this connection
@@ -32,12 +34,13 @@ public class ConnectionParams {
3234
* @param saslConfig sasl configuration hook
3335
* @param networkRecoveryInterval interval used when recovering from network failure
3436
* @param topologyRecovery should topology (queues, exchanges, bindings, consumers) recovery be performed?
37+
* @param threadFactory
3538
*/
3639
public ConnectionParams(String username, String password, ExecutorService executor,
3740
String virtualHost, Map<String, Object> clientProperties,
3841
int requestedFrameMax, int requestedChannelMax, int requestedHeartbeat,
3942
SaslConfig saslConfig, int networkRecoveryInterval,
40-
boolean topologyRecovery) {
43+
boolean topologyRecovery, ThreadFactory threadFactory) {
4144
this.username = username;
4245
this.password = password;
4346
this.executor = executor;
@@ -51,6 +54,7 @@ public ConnectionParams(String username, String password, ExecutorService execut
5154
this.topologyRecovery = topologyRecovery;
5255

5356
this.exceptionHandler = new DefaultExceptionHandler();
57+
this.threadFactory = threadFactory;
5458
}
5559

5660
public String getUsername() {
@@ -109,4 +113,8 @@ public int getNetworkRecoveryInterval() {
109113
public boolean isTopologyRecoveryEnabled() {
110114
return topologyRecovery;
111115
}
116+
117+
public ThreadFactory getThreadFactory() {
118+
return threadFactory;
119+
}
112120
}

0 commit comments

Comments
 (0)