Examples of QueueingConsumer


Examples of com.rabbitmq.client.QueueingConsumer

        this.sessionTTL = 100;
        publish(MSG[1]);

        Thread.sleep(200);

        QueueingConsumer c = new QueueingConsumer(channel);
        channel.basicConsume(TTL_QUEUE_NAME, c);

        assertNotNull("Message unexpectedly expired", c.nextDelivery(100));
        assertNull("Message should have been expired!!", c.nextDelivery(100));
    }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

      queueNames = new String[j];
      for (int i = 0; i < j; i++) {
        queueNames[i] = randomString();
        channel.queueDeclare(queueNames[i], durable, false, false, null);
        channel.queueBind(queueNames[i], binding.x, binding.k);
        channel.basicConsume(queueNames[i], true, new QueueingConsumer(channel));
      }
    }
    subscribeSendUnsubscribe(binding);
    if (durable) {
      restart();
    }
    if (queues > 1) {
      for (String s : queueNames) {
        channel.basicConsume(s, true, new QueueingConsumer(channel));
        Binding tmp = new Binding(s, binding.x, binding.k);
        sendUnroutable(tmp);
      }
    }
    channel.queueDeclare(binding.q, durable, true, true, null);
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    createQueueAndBindToExchange(binding, durable);
    return binding;
  }

  protected void subscribeSendUnsubscribe(Binding binding) throws IOException {
    String tag = channel.basicConsume(binding.q, new QueueingConsumer(channel));
    sendUnroutable(binding);
    channel.basicCancel(tag);
  }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    /*
    * Test expiry of re-queued messages after being consumed instantly
    */
    public void testExpiryWithReQueueAfterConsume() throws Exception {
        declareAndBindQueue(100);
        QueueingConsumer c = new QueueingConsumer(channel);
        channel.basicConsume(TTL_QUEUE_NAME, c);

        publish(MSG[0]);
        assertNotNull(c.nextDelivery(100));

        closeChannel();
        Thread.sleep(150);
        openChannel();

View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

        // when there is no consumer, message should expire
        publish(MSG[0]);
        assertNull(get());

        // when there is a consumer, message should be delivered
        QueueingConsumer c = new QueueingConsumer(channel);
        channel.basicConsume(TTL_QUEUE_NAME, c);
        publish(MSG[0]);
        QueueingConsumer.Delivery d = c.nextDelivery(100);
        assertNotNull(d);

        // requeued messages should expire
        channel.basicReject(d.getEnvelope().getDeliveryTag(), true);
        assertNull(c.nextDelivery(100));
    }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    public void testQueueAutoDelete() throws IOException {
        String name = "tempqueue";
        channel.queueDeclare(name, false, false, true, null);
        // now it's there
        verifyQueue(name, false, false, true, null);
        QueueingConsumer consumer = new QueueingConsumer(channel);
        String consumerTag = channel.basicConsume(name, consumer);
        channel.basicCancel(consumerTag);
        // now it's not .. we hope
        try {
            verifyQueueExists(name);
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    public void testExclusiveNotAutoDelete() throws IOException {
        String name = "exclusivequeue";
        channel.queueDeclare(name, false, true, false, null);
        // now it's there
        verifyQueue(name, false, true, false, null);
        QueueingConsumer consumer = new QueueingConsumer(channel);
        String consumerTag = channel.basicConsume(name, consumer);
        channel.basicCancel(consumerTag);
        // and still there, because exclusive no longer implies autodelete
        verifyQueueExists(name);
    }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    public void testConsumerCancellationNotification() throws IOException,
            InterruptedException {
        final BlockingQueue<Boolean> result = new ArrayBlockingQueue<Boolean>(1);

        channel.queueDeclare(queue, false, true, false, null);
        Consumer consumer = new QueueingConsumer(channel) {
            @Override
            public void handleCancel(String consumerTag) throws IOException {
                try {
                    result.put(true);
                } catch (InterruptedException e) {
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    public void testConsumerCancellationInterruptsQueuingConsumerWait()
            throws IOException, InterruptedException {
        final BlockingQueue<Boolean> result = new ArrayBlockingQueue<Boolean>(1);
        channel.queueDeclare(queue, false, true, false, null);
        final QueueingConsumer consumer = new QueueingConsumer(channel);
        Runnable receiver = new Runnable() {

            public void run() {
                try {
                    try {
                        consumer.nextDelivery();
                    } catch (ConsumerCancelledException e) {
                        result.put(true);
                        return;
                    } catch (ShutdownSignalException e) {
                    } catch (InterruptedException e) {
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

        basicPublishVolatile(m1, q);
        basicPublishVolatile(m2, q);

        long tag1 = checkDelivery(channel.basicGet(q, false), m1, false);
        long tag2 = checkDelivery(channel.basicGet(q, false), m2, false);
        QueueingConsumer c = new QueueingConsumer(secondaryChannel);
        String consumerTag = secondaryChannel.basicConsume(q, false, c);
        channel.basicReject(tag2, true);
        long tag3 = checkDelivery(c.nextDelivery(), m2, true);
        secondaryChannel.basicCancel(consumerTag);
        secondaryChannel.basicReject(tag3, false);
        assertNull(channel.basicGet(q, false));
        channel.basicAck(tag1, false);
        channel.basicReject(tag3, false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.