15
15
16
16
package com .rabbitmq .client .test .server ;
17
17
18
+ import com .rabbitmq .client .AMQP ;
19
+ import com .rabbitmq .client .Channel ;
18
20
import com .rabbitmq .client .MessageProperties ;
19
21
import com .rabbitmq .client .test .ConfirmBase ;
20
22
23
+ import java .io .IOException ;
24
+
21
25
public class MessageRecovery extends ConfirmBase
22
26
{
23
27
24
28
private final static String Q = "recovery-test" ;
29
+ private final static String Q2 = "recovery-test-ha-check" ;
25
30
26
31
public void testMessageRecovery ()
27
32
throws Exception
@@ -33,11 +38,28 @@ public void testMessageRecovery()
33
38
"nop" .getBytes ());
34
39
waitForConfirms ();
35
40
41
+ channel .queueDeclare (Q2 , false , false , false , null );
42
+
36
43
restart ();
37
44
38
- // When testing in HA mode the message will be collected from a promoted
39
- // slave and wil have its redelivered flag set.
40
- assertDelivered (Q , 1 , HATests .HA_TESTS_RUNNING );
45
+ // When testing in HA mode the message will be collected from
46
+ // a promoted slave and will have its redelivered flag
47
+ // set. But that only happens if there actually *is* a
48
+ // slave. We test that by passively declaring, and
49
+ // subsequently deletign, the secondary, non-durable queue,
50
+ // which only succeeds if the queue survived the restart,
51
+ // which in turn implies that it must have been a HA queue
52
+ // with slave(s).
53
+ boolean expectDelivered = false ;
54
+ try {
55
+ channel .queueDeclarePassive (Q2 );
56
+ channel .queueDelete (Q2 );
57
+ expectDelivered = true ;
58
+ } catch (IOException e ) {
59
+ checkShutdownSignal (AMQP .NOT_FOUND , e );
60
+ openChannel ();
61
+ }
62
+ assertDelivered (Q , 1 , expectDelivered );
41
63
channel .queueDelete (Q );
42
64
}
43
65
0 commit comments