Esempio n. 1
0
  public static IPersistentMap mapFrom(AMQP.Queue.DeclareOk method) {
    Map m = new HashMap();
    m.put(RT.keyword(null, "queue"), method.getQueue());
    m.put(RT.keyword(null, "message-count"), method.getMessageCount());
    m.put(RT.keyword(null, "consumer-count"), method.getConsumerCount());
    m.put(RT.keyword(null, "message_count"), method.getMessageCount());
    m.put(RT.keyword(null, "consumer_count"), method.getConsumerCount());

    return PersistentHashMap.create(m);
  }
Esempio n. 2
0
 private void expectQueueRecovery(Channel ch, String q)
     throws IOException, InterruptedException, TimeoutException {
   ch.confirmSelect();
   ch.queuePurge(q);
   AMQP.Queue.DeclareOk ok1 = declareClientNamedQueue(ch, q);
   assertEquals(0, ok1.getMessageCount());
   ch.basicPublish("", q, null, "msg".getBytes());
   waitForConfirms(ch);
   AMQP.Queue.DeclareOk ok2 = declareClientNamedQueue(ch, q);
   assertEquals(1, ok2.getMessageCount());
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
 // bug 26552
 public void testClientNamedTransientAutoDeleteQueueAndBindingRecovery()
     throws IOException, InterruptedException, TimeoutException {
   String q = UUID.randomUUID().toString();
   String x = "tmp-fanout";
   Channel ch = connection.createChannel();
   ch.queueDelete(q);
   ch.exchangeDelete(x);
   ch.exchangeDeclare(x, "fanout");
   ch.queueDeclare(q, false, false, true, null);
   ch.queueBind(q, x, "");
   restartPrimaryAndWaitForRecovery();
   expectChannelRecovery(ch);
   ch.confirmSelect();
   ch.queuePurge(q);
   ch.exchangeDeclare(x, "fanout");
   ch.basicPublish(x, "", null, "msg".getBytes());
   waitForConfirms(ch);
   AMQP.Queue.DeclareOk ok = ch.queueDeclare(q, false, false, true, null);
   assertEquals(1, ok.getMessageCount());
   ch.queueDelete(q);
   ch.exchangeDelete(x);
 }
Esempio n. 5
0
 public int getMessageCount() {
   return method.getMessageCount();
 }