2121import java .security .NoSuchAlgorithmException ;
2222import java .util .Map ;
2323import java .util .concurrent .ExecutorService ;
24- import java .util .concurrent .Executors ;
2524
2625import java .net .InetSocketAddress ;
2726import java .net .Socket ;
4342 */
4443
4544public class ConnectionFactory implements Cloneable {
46-
45+
4746 /** Default Executor threads */
47+ @ Deprecated
4848 public static final int DEFAULT_NUM_CONSUMER_THREADS = 5 ;
4949 /** Default user name */
5050 public static final String DEFAULT_USER = "guest" ;
@@ -76,7 +76,6 @@ public class ConnectionFactory implements Cloneable {
7676 /** The default SSL protocol */
7777 private static final String DEFAULT_SSL_PROTOCOL = "SSLv3" ;
7878
79- private int numConsumerThreads = DEFAULT_NUM_CONSUMER_THREADS ;
8079 private String username = DEFAULT_USER ;
8180 private String password = DEFAULT_PASS ;
8281 private String virtualHost = DEFAULT_VHOST ;
@@ -91,13 +90,15 @@ public class ConnectionFactory implements Cloneable {
9190 private SaslConfig saslConfig = DefaultSaslConfig .PLAIN ;
9291
9392 /** @return number of consumer threads in default {@link ExecutorService} */
93+ @ Deprecated
9494 public int getNumConsumerThreads () {
95- return numConsumerThreads ;
95+ return DEFAULT_NUM_CONSUMER_THREADS ;
9696 }
9797
9898 /** @param numConsumerThreads threads in created private executor service */
99+ @ Deprecated
99100 public void setNumConsumerThreads (int numConsumerThreads ) {
100- this . numConsumerThreads = numConsumerThreads ;
101+ throw new IllegalArgumentException ( "setNumConsumerThreads not supported -- create explicit ExecutorService instead." ) ;
101102 }
102103
103104 /** @return the default host to use for connections */
@@ -472,8 +473,7 @@ protected void configureSocket(Socket socket) throws IOException{
472473 * @throws IOException if it encounters a problem
473474 */
474475 public Connection newConnection (Address [] addrs ) throws IOException {
475- return newConnection (Executors .newFixedThreadPool (this .numConsumerThreads ),
476- addrs );
476+ return newConnection (null , addrs );
477477 }
478478
479479 /**
@@ -490,7 +490,7 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
490490 for (Address addr : addrs ) {
491491 try {
492492 FrameHandler frameHandler = createFrameHandler (addr );
493- AMQConnection conn =
493+ AMQConnection conn =
494494 new AMQConnection (username ,
495495 password ,
496496 frameHandler ,
@@ -518,7 +518,7 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
518518 * @throws IOException if it encounters a problem
519519 */
520520 public Connection newConnection () throws IOException {
521- return newConnection (Executors . newFixedThreadPool ( this . numConsumerThreads ) ,
521+ return newConnection (null ,
522522 new Address [] {new Address (getHost (), getPort ())}
523523 );
524524 }
0 commit comments