@@ -470,27 +470,7 @@ protected final Connection createBareConnection() {
470
470
try {
471
471
String connectionName = this .connectionNameStrategy .obtainNewConnectionName (this );
472
472
473
- com .rabbitmq .client .Connection rabbitConnection ;
474
- if (this .addresses != null ) {
475
- List <Address > addressesToConnect = this .addresses ;
476
- if (this .shuffleAddresses && addressesToConnect .size () > 1 ) {
477
- List <Address > list = new ArrayList <>(addressesToConnect );
478
- Collections .shuffle (list );
479
- addressesToConnect = list ;
480
- }
481
- if (this .logger .isInfoEnabled ()) {
482
- this .logger .info ("Attempting to connect to: " + addressesToConnect );
483
- }
484
- rabbitConnection = this .rabbitConnectionFactory .newConnection (this .executorService , addressesToConnect ,
485
- connectionName );
486
- }
487
- else {
488
- if (this .logger .isInfoEnabled ()) {
489
- this .logger .info ("Attempting to connect to: " + this .rabbitConnectionFactory .getHost ()
490
- + ":" + this .rabbitConnectionFactory .getPort ());
491
- }
492
- rabbitConnection = this .rabbitConnectionFactory .newConnection (this .executorService , connectionName );
493
- }
473
+ com .rabbitmq .client .Connection rabbitConnection = connect (connectionName );
494
474
495
475
Connection connection = new SimpleConnection (rabbitConnection , this .closeTimeout );
496
476
if (rabbitConnection instanceof AutorecoveringConnection ) {
@@ -531,6 +511,31 @@ public void handleRecovery(Recoverable recoverable) {
531
511
}
532
512
}
533
513
514
+ private com .rabbitmq .client .Connection connect (String connectionName ) throws IOException , TimeoutException {
515
+ com .rabbitmq .client .Connection rabbitConnection ;
516
+ if (this .addresses != null ) {
517
+ List <Address > addressesToConnect = this .addresses ;
518
+ if (this .shuffleAddresses && addressesToConnect .size () > 1 ) {
519
+ List <Address > list = new ArrayList <>(addressesToConnect );
520
+ Collections .shuffle (list );
521
+ addressesToConnect = list ;
522
+ }
523
+ if (this .logger .isInfoEnabled ()) {
524
+ this .logger .info ("Attempting to connect to: " + addressesToConnect );
525
+ }
526
+ rabbitConnection = this .rabbitConnectionFactory .newConnection (this .executorService , addressesToConnect ,
527
+ connectionName );
528
+ }
529
+ else {
530
+ if (this .logger .isInfoEnabled ()) {
531
+ this .logger .info ("Attempting to connect to: " + this .rabbitConnectionFactory .getHost ()
532
+ + ":" + this .rabbitConnectionFactory .getPort ());
533
+ }
534
+ rabbitConnection = this .rabbitConnectionFactory .newConnection (this .executorService , connectionName );
535
+ }
536
+ return rabbitConnection ;
537
+ }
538
+
534
539
protected final String getDefaultHostName () {
535
540
String temp ;
536
541
try {
0 commit comments