Package com.rabbitmq.client

Examples of com.rabbitmq.client.QueueingConsumer


        channel.queueBind(q, "amq.fanout", "");

        final Map<String, Integer> counts =
            Collections.synchronizedMap(new HashMap<String, Integer>());

        QueueingConsumer c = new QueueingConsumer(channel) {
                @Override public void handleDelivery(String consumerTag,
                                                     Envelope envelope,
                                                     AMQP.BasicProperties properties,
                                                     byte[] body)
                    throws IOException {
                    counts.put(consumerTag, counts.get(consumerTag) + 1);
                    super.handleDelivery(consumerTag, envelope,
                                         properties, body);
                }
            };

        channel.basicConsume(q, false, "c1", c);
        channel.basicConsume(q, false, "c2", c);

        int count = 10;
        counts.put("c1", 0);
        counts.put("c2", 0);
        fill(count);
        try {
            for (int i = 0; i < count; i++) {
                Delivery d = c.nextDelivery();
                channel.basicAck(d.getEnvelope().getDeliveryTag(), false);
            }
        } catch (InterruptedException ie) {
            fail("interrupted");
        }
View Full Code Here


    public void testConsumerLifecycle()
        throws IOException
    {
        channel.basicQos(1);
        QueueingConsumer c = new QueueingConsumer(channel);
        String queue = "qosTest";
        channel.queueDeclare(queue, false, false, false, null);
        channel.queueBind(queue, "amq.fanout", "");
        fill(3);
        String tag;
View Full Code Here

    }

    public void testSetLimitAfterConsume()
        throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        declareBindConsume(c);
        channel.basicQos(1);
        fill(3);
        //We actually only guarantee that the limit takes effect
        //*eventually*, so this can in fact fail. It's pretty unlikely
View Full Code Here

    }

    public void testLimitIncrease()
        throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        configure(c, 1, 3);
        channel.basicQos(2);
        drain(c, 1);
    }
View Full Code Here

    }

    public void testLimitDecrease()
        throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        Queue<Delivery> d = configure(c, 2, 4);
        channel.basicQos(1);
        drain(c, 0);
        ack(d, true);
        drain(c, 1);
View Full Code Here

    }

    public void testLimitedToUnlimited()
        throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        configure(c, 1, 3);
        channel.basicQos(0);
        drain(c, 2);
    }
View Full Code Here

    public void testLimitingMultipleChannels()
        throws IOException
    {
        Channel ch1 = connection.createChannel();
        Channel ch2 = connection.createChannel();
        QueueingConsumer c1 = new QueueingConsumer(ch1);
        QueueingConsumer c2 = new QueueingConsumer(ch2);
        String q1 = declareBindConsume(ch1, c1, false);
        String q2 = declareBindConsume(ch2, c2, false);
        ch1.basicConsume(q2, false, c1);
        ch2.basicConsume(q1, false, c2);
        ch1.basicQos(1);
View Full Code Here

    }

    public void testLimitInheritsUnackedCount()
        throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        declareBindConsume(c);
        fill(1);
        drain(c, 1);
        channel.basicQos(2);
        fill(2);
View Full Code Here

        drain(c, 1);
    }

    public void testFlow() throws IOException
    {
        QueueingConsumer c = new QueueingConsumer(channel);
        declareBindConsume(c);
        fill(1);
        drain(c, 1);
        channel.flow(false);
        fill(1);
View Full Code Here

    }

    public void testLimitAndFlow() throws IOException
    {
        channel.basicQos(1);
        QueueingConsumer c = new QueueingConsumer(channel);
        declareBindConsume(c);
        channel.flow(false);
        fill(3);
        drain(c, 0);
        channel.flow(true);
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.QueueingConsumer

Copyright © 2018 www.massapicom. 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.