16
16
package com .rabbitmq .client .test .functional ;
17
17
18
18
import com .rabbitmq .client .*;
19
- import com .rabbitmq .client .impl .recovery .*;
19
+ import com .rabbitmq .client .impl .NetworkConnection ;
20
+ import com .rabbitmq .client .impl .recovery .AutorecoveringConnection ;
21
+ import com .rabbitmq .client .impl .recovery .ConsumerRecoveryListener ;
22
+ import com .rabbitmq .client .impl .recovery .QueueRecoveryListener ;
23
+ import com .rabbitmq .client .impl .recovery .RecoveryCanBeginListener ;
20
24
import com .rabbitmq .client .test .BrokerTestCase ;
21
25
import com .rabbitmq .client .test .TestUtils ;
22
26
import com .rabbitmq .tools .Host ;
@@ -49,7 +53,7 @@ public class ConnectionRecovery extends BrokerTestCase {
49
53
@ Test public void namedConnectionRecovery ()
50
54
throws IOException , InterruptedException , TimeoutException {
51
55
String connectionName = "custom name" ;
52
- AutorecoveringConnection c = newRecoveringConnection (connectionName );
56
+ RecoverableConnection c = newRecoveringConnection (connectionName );
53
57
try {
54
58
assertTrue (c .isOpen ());
55
59
assertEquals (connectionName , c .getClientProvidedName ());
@@ -70,7 +74,7 @@ public class ConnectionRecovery extends BrokerTestCase {
70
74
@ Test public void connectionRecoveryWithArrayOfAddresses ()
71
75
throws IOException , InterruptedException , TimeoutException {
72
76
final Address [] addresses = {new Address ("127.0.0.1" ), new Address ("127.0.0.1" , 5672 )};
73
- AutorecoveringConnection c = newRecoveringConnection (addresses );
77
+ RecoverableConnection c = newRecoveringConnection (addresses );
74
78
try {
75
79
assertTrue (c .isOpen ());
76
80
closeAndWaitForRecovery (c );
@@ -86,7 +90,7 @@ public class ConnectionRecovery extends BrokerTestCase {
86
90
87
91
final List <Address > addresses = Arrays .asList (new Address ("127.0.0.1" ), new Address ("127.0.0.1" , 5672 ));
88
92
89
- AutorecoveringConnection c = newRecoveringConnection (addresses );
93
+ RecoverableConnection c = newRecoveringConnection (addresses );
90
94
try {
91
95
assertTrue (c .isOpen ());
92
96
closeAndWaitForRecovery (c );
@@ -98,7 +102,7 @@ public class ConnectionRecovery extends BrokerTestCase {
98
102
99
103
@ Test public void connectionRecoveryWithDisabledTopologyRecovery ()
100
104
throws IOException , InterruptedException , TimeoutException {
101
- AutorecoveringConnection c = newRecoveringConnection (true );
105
+ RecoverableConnection c = newRecoveringConnection (true );
102
106
Channel ch = c .createChannel ();
103
107
String q = "java-client.test.recovery.q2" ;
104
108
ch .queueDeclare (q , false , true , false , null );
@@ -107,7 +111,7 @@ public class ConnectionRecovery extends BrokerTestCase {
107
111
try {
108
112
CountDownLatch shutdownLatch = prepareForShutdown (c );
109
113
CountDownLatch recoveryLatch = prepareForRecovery (c );
110
- Host .closeConnection (c );
114
+ Host .closeConnection (( NetworkConnection ) c );
111
115
wait (shutdownLatch );
112
116
wait (recoveryLatch );
113
117
assertTrue (c .isOpen ());
@@ -144,7 +148,7 @@ public void recoveryCanBegin(ShutdownSignalException cause) {
144
148
recoveryCanBeginLatch .countDown ();
145
149
}
146
150
});
147
- ((AutorecoveringConnection )connection ).addRecoveryListener (new RecoveryListener () {
151
+ ((RecoverableConnection )connection ).addRecoveryListener (new RecoveryListener () {
148
152
@ Override
149
153
public void handleRecovery (Recoverable recoverable ) {
150
154
latch .countDown ();
@@ -635,9 +639,9 @@ public void handleRecoveryStarted(Recoverable recoverable) {
635
639
startLatch .countDown ();
636
640
}
637
641
};
638
- AutorecoveringChannel ch1 = (AutorecoveringChannel ) connection .createChannel ();
642
+ RecoverableChannel ch1 = (RecoverableChannel ) connection .createChannel ();
639
643
ch1 .addRecoveryListener (listener );
640
- AutorecoveringChannel ch2 = (AutorecoveringChannel ) connection .createChannel ();
644
+ RecoverableChannel ch2 = (RecoverableChannel ) connection .createChannel ();
641
645
ch2 .addRecoveryListener (listener );
642
646
643
647
assertTrue (ch1 .isOpen ());
@@ -677,7 +681,7 @@ public void handleDelivery(String consumerTag,
677
681
678
682
String q = channel .queueDeclare ().getQueue ();
679
683
channel .basicConsume (q , consumer );
680
- AutorecoveringConnection publishingConnection = newRecoveringConnection (false );
684
+ RecoverableConnection publishingConnection = newRecoveringConnection (false );
681
685
Channel publishingChannel = publishingConnection .createChannel ();
682
686
for (int i = 0 ; i < n ; i ++) {
683
687
publishingChannel .basicPublish ("" , q , null , "msg" .getBytes ());
@@ -772,9 +776,9 @@ private void closeAndWaitForRecovery() throws IOException, InterruptedException
772
776
closeAndWaitForRecovery ((AutorecoveringConnection )this .connection );
773
777
}
774
778
775
- private void closeAndWaitForRecovery (AutorecoveringConnection connection ) throws IOException , InterruptedException {
779
+ private void closeAndWaitForRecovery (RecoverableConnection connection ) throws IOException , InterruptedException {
776
780
CountDownLatch latch = prepareForRecovery (connection );
777
- Host .closeConnection (connection );
781
+ Host .closeConnection (( NetworkConnection ) connection );
778
782
wait (latch );
779
783
}
780
784
@@ -799,37 +803,37 @@ protected ConnectionFactory newConnectionFactory() {
799
803
return buildConnectionFactoryWithRecoveryEnabled (false );
800
804
}
801
805
802
- private AutorecoveringConnection newRecoveringConnection (boolean disableTopologyRecovery )
806
+ private RecoverableConnection newRecoveringConnection (boolean disableTopologyRecovery )
803
807
throws IOException , TimeoutException {
804
808
ConnectionFactory cf = buildConnectionFactoryWithRecoveryEnabled (disableTopologyRecovery );
805
809
return (AutorecoveringConnection ) cf .newConnection ();
806
810
}
807
811
808
- private AutorecoveringConnection newRecoveringConnection (Address [] addresses )
812
+ private RecoverableConnection newRecoveringConnection (Address [] addresses )
809
813
throws IOException , TimeoutException {
810
814
ConnectionFactory cf = buildConnectionFactoryWithRecoveryEnabled (false );
811
815
// specifically use the Address[] overload
812
816
return (AutorecoveringConnection ) cf .newConnection (addresses );
813
817
}
814
818
815
- private AutorecoveringConnection newRecoveringConnection (boolean disableTopologyRecovery , List <Address > addresses )
819
+ private RecoverableConnection newRecoveringConnection (boolean disableTopologyRecovery , List <Address > addresses )
816
820
throws IOException , TimeoutException {
817
821
ConnectionFactory cf = buildConnectionFactoryWithRecoveryEnabled (disableTopologyRecovery );
818
822
return (AutorecoveringConnection ) cf .newConnection (addresses );
819
823
}
820
824
821
- private AutorecoveringConnection newRecoveringConnection (List <Address > addresses )
825
+ private RecoverableConnection newRecoveringConnection (List <Address > addresses )
822
826
throws IOException , TimeoutException {
823
827
return newRecoveringConnection (false , addresses );
824
828
}
825
829
826
- private AutorecoveringConnection newRecoveringConnection (boolean disableTopologyRecovery , String connectionName )
830
+ private RecoverableConnection newRecoveringConnection (boolean disableTopologyRecovery , String connectionName )
827
831
throws IOException , TimeoutException {
828
832
ConnectionFactory cf = buildConnectionFactoryWithRecoveryEnabled (disableTopologyRecovery );
829
- return (AutorecoveringConnection ) cf .newConnection (connectionName );
833
+ return (RecoverableConnection ) cf .newConnection (connectionName );
830
834
}
831
835
832
- private AutorecoveringConnection newRecoveringConnection (String connectionName )
836
+ private RecoverableConnection newRecoveringConnection (String connectionName )
833
837
throws IOException , TimeoutException {
834
838
return newRecoveringConnection (false , connectionName );
835
839
}
0 commit comments