|
34 | 34 | import javax.net.ssl.TrustManager; |
35 | 35 |
|
36 | 36 | import com.rabbitmq.client.impl.AMQConnection; |
| 37 | +import com.rabbitmq.client.impl.DefaultThreadFactory; |
37 | 38 | import com.rabbitmq.client.impl.FrameHandler; |
38 | 39 | import com.rabbitmq.client.impl.SocketFrameHandler; |
39 | 40 |
|
@@ -89,6 +90,7 @@ public class ConnectionFactory implements Cloneable { |
89 | 90 | private SocketFactory factory = SocketFactory.getDefault(); |
90 | 91 | private SaslConfig saslConfig = DefaultSaslConfig.PLAIN; |
91 | 92 | private ExecutorService sharedExecutor; |
| 93 | + private ThreadFactory threadFactory = new DefaultThreadFactory(); |
92 | 94 |
|
93 | 95 | /** @return number of consumer threads in default {@link ExecutorService} */ |
94 | 96 | @Deprecated |
@@ -398,6 +400,24 @@ public void setSharedExecutor(ExecutorService executor) { |
398 | 400 | this.sharedExecutor = executor; |
399 | 401 | } |
400 | 402 |
|
| 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 | + |
401 | 421 | public boolean isSSL(){ |
402 | 422 | return getSocketFactory() instanceof SSLSocketFactory; |
403 | 423 | } |
@@ -527,6 +547,7 @@ public Connection newConnection(ExecutorService executor, Address[] addrs) |
527 | 547 | requestedChannelMax, |
528 | 548 | requestedHeartbeat, |
529 | 549 | saslConfig); |
| 550 | + conn.setThreadFactory(this.threadFactory); |
530 | 551 | conn.start(); |
531 | 552 | return conn; |
532 | 553 | } catch (IOException e) { |
|
0 commit comments