Skip to content

Commit f80f618

Browse files
author
Matthias Radestock
committed
properly test durable binding recovery
we create the durable queue on the secondary node (if available), which gets fully restarted, rather than the primary node, on which only the rabbit app is restarted.
1 parent 4f557af commit f80f618

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/src/com/rabbitmq/client/test/functional/BindingLifecycle.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
package com.rabbitmq.client.test.functional;
3333

34+
import com.rabbitmq.client.Channel;
35+
import com.rabbitmq.client.Connection;
3436
import com.rabbitmq.client.GetResponse;
3537
import com.rabbitmq.client.QueueingConsumer;
3638

@@ -53,6 +55,29 @@ public class BindingLifecycle extends PersisterRestartBase {
5355
protected static final String X = "X-" + System.currentTimeMillis();
5456
protected static final String K = "K-" + System.currentTimeMillis();
5557

58+
/**
59+
* Create a durable queue on secondary node, if possible, falling
60+
* back on the primary node if necessary.
61+
*/
62+
@Override protected void declareDurableQueue(String q)
63+
throws IOException
64+
{
65+
Connection connection;
66+
try {
67+
connection = connectionFactory.newConnection("localhost", 5673);
68+
} catch (IOException e) {
69+
super.declareDurableQueue(q);
70+
return;
71+
}
72+
73+
Channel channel = connection.createChannel();
74+
75+
channel.queueDeclare(q, true);
76+
77+
channel.abort();
78+
connection.abort();
79+
}
80+
5681
/**
5782
* Tests whether durable bindings are correctly recovered.
5883
*/

0 commit comments

Comments
 (0)