|
12 | 12 | import java.util.UUID; |
13 | 13 | import java.util.concurrent.CountDownLatch; |
14 | 14 | import java.util.concurrent.TimeUnit; |
| 15 | +import java.util.concurrent.TimeoutException; |
15 | 16 | import java.util.concurrent.atomic.AtomicInteger; |
16 | 17 |
|
17 | 18 | public class ConnectionRecovery extends BrokerTestCase { |
@@ -110,6 +111,31 @@ public void handleReturn(int replyCode, String replyText, String exchange, |
110 | 111 | assertTrue(latch.await(150, TimeUnit.MILLISECONDS)); |
111 | 112 | } |
112 | 113 |
|
| 114 | + public void testConfirmListenerRecovery() throws IOException, InterruptedException, TimeoutException { |
| 115 | + int n = 10; |
| 116 | + String q = channel.queueDeclare(UUID.randomUUID().toString(), false, false, false, null).getQueue(); |
| 117 | + final CountDownLatch latch = new CountDownLatch(n); |
| 118 | + channel.addConfirmListener(new ConfirmListener() { |
| 119 | + @Override |
| 120 | + public void handleAck(long deliveryTag, boolean multiple) throws IOException { |
| 121 | + latch.countDown(); |
| 122 | + } |
| 123 | + |
| 124 | + @Override |
| 125 | + public void handleNack(long deliveryTag, boolean multiple) throws IOException { |
| 126 | + } |
| 127 | + }); |
| 128 | + channel.confirmSelect(); |
| 129 | + closeAndWaitForShutdown(connection); |
| 130 | + waitForRecovery(); |
| 131 | + expectChannelRecovery(channel); |
| 132 | + for (int i = 0; i < n; i++) { |
| 133 | + channel.basicPublish("", q, true, false, null, "mandatory1".getBytes()); |
| 134 | + } |
| 135 | + channel.waitForConfirms(200); |
| 136 | + assertTrue(latch.await(50, TimeUnit.MILLISECONDS)); |
| 137 | + } |
| 138 | + |
113 | 139 | public void testClientNamedQueueRecovery() throws IOException, InterruptedException { |
114 | 140 | Channel ch = connection.createChannel(); |
115 | 141 | String q = "java-client.test.recovery.q1"; |
|
0 commit comments