Skip to content

Commit f46422d

Browse files
Thread factory should be set via ConnectionFactory
1 parent 2bdaac8 commit f46422d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.net.ssl.TrustManager;
3535

3636
import com.rabbitmq.client.impl.AMQConnection;
37+
import com.rabbitmq.client.impl.DefaultThreadFactory;
3738
import com.rabbitmq.client.impl.FrameHandler;
3839
import com.rabbitmq.client.impl.SocketFrameHandler;
3940

@@ -89,6 +90,7 @@ public class ConnectionFactory implements Cloneable {
8990
private SocketFactory factory = SocketFactory.getDefault();
9091
private SaslConfig saslConfig = DefaultSaslConfig.PLAIN;
9192
private ExecutorService sharedExecutor;
93+
private ThreadFactory threadFactory = new DefaultThreadFactory();
9294

9395
/** @return number of consumer threads in default {@link ExecutorService} */
9496
@Deprecated
@@ -398,6 +400,24 @@ public void setSharedExecutor(ExecutorService executor) {
398400
this.sharedExecutor = executor;
399401
}
400402

403+
/**
404+
* Retrieve the socket factory used to instantiate new threads.
405+
* @see com.rabbitmq.client.ThreadFactory
406+
* @see com.rabbitmq.client.impl.DefaultThreadFactory
407+
*/
408+
public ThreadFactory getThreadFactory() {
409+
return threadFactory;
410+
}
411+
412+
/**
413+
* Set the thread factory to use for newly created connections.
414+
* @see com.rabbitmq.client.ThreadFactory
415+
* @see com.rabbitmq.client.impl.DefaultThreadFactory
416+
*/
417+
public void setThreadFactory(ThreadFactory threadFactory) {
418+
this.threadFactory = threadFactory;
419+
}
420+
401421
public boolean isSSL(){
402422
return getSocketFactory() instanceof SSLSocketFactory;
403423
}
@@ -527,6 +547,7 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
527547
requestedChannelMax,
528548
requestedHeartbeat,
529549
saslConfig);
550+
conn.setThreadFactory(this.threadFactory);
530551
conn.start();
531552
return conn;
532553
} catch (IOException e) {

0 commit comments

Comments
 (0)