Exemplo n.º 1
0
  public void testServerNamedQueueRecovery() throws IOException, InterruptedException {
    String q = channel.queueDeclare("", false, false, false, null).getQueue();
    String x = "amq.fanout";
    channel.queueBind(q, x, "");

    final AtomicReference<String> nameBefore = new AtomicReference<String>();
    final AtomicReference<String> nameAfter = new AtomicReference<String>();
    final CountDownLatch listenerLatch = new CountDownLatch(1);
    ((AutorecoveringConnection) connection)
        .addQueueRecoveryListener(
            new QueueRecoveryListener() {
              @Override
              public void queueRecovered(String oldName, String newName) {
                nameBefore.set(oldName);
                nameAfter.set(newName);
                listenerLatch.countDown();
              }
            });

    closeAndWaitForRecovery();
    wait(listenerLatch);
    expectChannelRecovery(channel);
    channel.basicPublish(x, "", null, "msg".getBytes());
    assertDelivered(q, 1);
    assertFalse(nameBefore.get().equals(nameAfter.get()));
    channel.queueDelete(q);
  }
Exemplo n.º 2
0
 // bug 26552
 public void testServerNamedTransientAutoDeleteQueueAndBindingRecovery()
     throws IOException, InterruptedException, TimeoutException {
   String x = "tmp-fanout";
   Channel ch = connection.createChannel();
   ch.exchangeDelete(x);
   ch.exchangeDeclare(x, "fanout");
   String q = ch.queueDeclare("", false, false, true, null).getQueue();
   final AtomicReference<String> nameBefore = new AtomicReference<String>(q);
   final AtomicReference<String> nameAfter = new AtomicReference<String>();
   final CountDownLatch listenerLatch = new CountDownLatch(1);
   ((AutorecoveringConnection) connection)
       .addQueueRecoveryListener(
           new QueueRecoveryListener() {
             @Override
             public void queueRecovered(String oldName, String newName) {
               nameBefore.set(oldName);
               nameAfter.set(newName);
               listenerLatch.countDown();
             }
           });
   ch.queueBind(nameBefore.get(), x, "");
   restartPrimaryAndWaitForRecovery();
   expectChannelRecovery(ch);
   ch.confirmSelect();
   ch.exchangeDeclare(x, "fanout");
   ch.basicPublish(x, "", null, "msg".getBytes());
   waitForConfirms(ch);
   AMQP.Queue.DeclareOk ok = ch.queueDeclarePassive(nameAfter.get());
   assertEquals(1, ok.getMessageCount());
   ch.queueDelete(nameAfter.get());
   ch.exchangeDelete(x);
 }