1515
1616package com .rabbitmq .client .test .server ;
1717
18+ import com .rabbitmq .client .AMQP ;
19+ import com .rabbitmq .client .Channel ;
1820import com .rabbitmq .client .MessageProperties ;
1921import com .rabbitmq .client .test .ConfirmBase ;
2022
23+ import java .io .IOException ;
24+
2125public class MessageRecovery extends ConfirmBase
2226{
2327
2428 private final static String Q = "recovery-test" ;
29+ private final static String Q2 = "recovery-test-ha-check" ;
2530
2631 public void testMessageRecovery ()
2732 throws Exception
@@ -33,11 +38,28 @@ public void testMessageRecovery()
3338 "nop" .getBytes ());
3439 waitForConfirms ();
3540
41+ channel .queueDeclare (Q2 , false , false , false , null );
42+
3643 restart ();
3744
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 );
4163 channel .queueDelete (Q );
4264 }
4365
0 commit comments