File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
test/src/com/rabbitmq/client/test/functional Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 5252 * Convenience "factory" class to facilitate opening a {@link Connection} to an AMQP broker.
5353 */
5454
55- public class ConnectionFactory {
55+ public class ConnectionFactory implements Cloneable {
5656 /** Default user name */
5757 public static final String DEFAULT_USER = "guest" ;
5858
@@ -399,4 +399,13 @@ public Connection newConnection() throws IOException {
399399 0 ,
400400 new HashMap <Address ,Integer >());
401401 }
402+
403+
404+ @ Override public ConnectionFactory clone (){
405+ try {
406+ return (ConnectionFactory )super .clone ();
407+ } catch (CloneNotSupportedException e ) {
408+ throw new Error (e );
409+ }
410+ }
402411}
Original file line number Diff line number Diff line change 3838import com .rabbitmq .client .Connection ;
3939import com .rabbitmq .client .GetResponse ;
4040import com .rabbitmq .client .QueueingConsumer ;
41+ import com .rabbitmq .client .ConnectionFactory ;
4142import java .io .IOException ;
4243
4344/**
@@ -75,9 +76,10 @@ public void openConnection() throws IOException {
7576 super .openConnection ();
7677 if (secondaryConnection == null ) {
7778 try {
78- connectionFactory .setHost ("localhost" );
79- connectionFactory .setPort (5673 );
80- secondaryConnection = connectionFactory .newConnection ();
79+ ConnectionFactory cf2 = connectionFactory .clone ();
80+ cf2 .setHost ("localhost" );
81+ cf2 .setPort (5673 );
82+ secondaryConnection = cf2 .newConnection ();
8183 }
8284 catch (IOException e ) {
8385 }
You can’t perform that action at this time.
0 commit comments