|
9 | 9 | import com.rabbitmq.tools.Host;
|
10 | 10 |
|
11 | 11 | import java.io.IOException;
|
| 12 | +import java.util.List; |
| 13 | +import java.util.ArrayList; |
12 | 14 | import java.util.UUID;
|
13 | 15 | import java.util.concurrent.CountDownLatch;
|
14 | 16 | import java.util.concurrent.TimeUnit;
|
@@ -259,17 +261,33 @@ public void testThatDeletedQueueDoesNotReappearOnRecover() throws IOException, I
|
259 | 261 | }
|
260 | 262 | }
|
261 | 263 |
|
262 |
| - public void testThatCancelledConsumerDoesNotReappearOnRecover() throws IOException, InterruptedException { |
263 |
| - String q = UUID.randomUUID().toString(); |
264 |
| - channel.queueDeclare(q, false, false, false, null); |
265 |
| - String tag = channel.basicConsume(q, new DefaultConsumer(channel)); |
| 264 | + public void testConsumerRecoveryWithManyConsumers() throws IOException, InterruptedException { |
| 265 | + String q = channel.queueDeclare(UUID.randomUUID().toString(), false, false, false, null).getQueue(); |
| 266 | + final int n = 1024; |
| 267 | + for (int i = 0; i < n; i++) { |
| 268 | + channel.basicConsume(q, new DefaultConsumer(channel)); |
| 269 | + } |
266 | 270 | AMQP.Queue.DeclareOk ok1 = channel.queueDeclarePassive(q);
|
267 |
| - assertEquals(1, ok1.getConsumerCount()); |
268 |
| - channel.basicCancel(tag); |
| 271 | + assertEquals(n, ok1.getConsumerCount()); |
269 | 272 | closeAndWaitForRecovery();
|
270 | 273 | expectChannelRecovery(channel);
|
271 | 274 | AMQP.Queue.DeclareOk ok2 = channel.queueDeclarePassive(q);
|
272 |
| - assertEquals(0, ok2.getConsumerCount()); |
| 275 | + assertEquals(n, ok2.getConsumerCount()); |
| 276 | + |
| 277 | + } |
| 278 | + |
| 279 | + public void testQueueRecoveryWithManyQueues() throws IOException, InterruptedException, TimeoutException { |
| 280 | + List<String> qs = new ArrayList<String>(); |
| 281 | + final int n = 1024; |
| 282 | + for (int i = 0; i < n; i++) { |
| 283 | + qs.add(channel.queueDeclare(UUID.randomUUID().toString(), true, false, false, null).getQueue()); |
| 284 | + } |
| 285 | + closeAndWaitForRecovery(); |
| 286 | + expectChannelRecovery(channel); |
| 287 | + for(String q : qs) { |
| 288 | + expectQueueRecovery(channel, q); |
| 289 | + channel.queueDelete(q); |
| 290 | + } |
273 | 291 | }
|
274 | 292 |
|
275 | 293 | public void testChannelRecoveryCallback() throws IOException, InterruptedException {
|
|
0 commit comments