Package com.rabbitmq.client

Examples of com.rabbitmq.client.GetResponse


    }

    private List<Long> getUnacked(int howMany) throws IOException {
        List<Long> tags = new ArrayList<Long>(howMany);
        for (;howMany > 0; howMany --) {
            GetResponse response = channel.basicGet(q, false);
            tags.add(response.getEnvelope().getDeliveryTag());
        }
        return tags;
    }
View Full Code Here


        List<Delivery> d = drain(c, limit);

        //is basic.get not limited?
        List<Long> tags = new ArrayList<Long>();
        for (String q : queues) {
            GetResponse r = channel.basicGet(q, false);
            assertNotNull(r);
            tags.add(r.getEnvelope().getDeliveryTag());
        }

        //are acks handled correctly?
        //and does the basic.get above have no effect on limiting?
        Delivery last = ack(d, multiAck);
View Full Code Here

    {
        openConnection();
        for (int repeat = 0; repeat < count; repeat++) {
            open();
            injectMessage();
            GetResponse r1 = getMessage();
            if (doAck) channel.basicAck(r1.getEnvelope().getDeliveryTag(), false);
            close();
            open();
            if (doAck) {
                assertNull("Expected missing second basicGet (repeat="+repeat+")", getMessage());
            } else {
View Full Code Here

     *
     * @param queue The queue name
     * @throws IOException
     */
    public void queueNotEmtpy(String queue) throws IOException {
        GetResponse response = channel.basicGet(queue, false);
        Assert.assertNotNull(response);
        channel.basicNack(response.getEnvelope().getDeliveryTag(), false, true);
    }
View Full Code Here

     *
     * @param queue The queue name
     * @throws IOException
     */
    public void queueEmtpy(String queue) throws IOException {
        GetResponse response = channel.basicGet(queue, false);
        if (response != null) {
            channel.basicNack(response.getEnvelope().getDeliveryTag(), false, true);
        }
        Assert.assertNull(response);
    }
View Full Code Here

     * @param queue The queue name
     * @param expectedCount The expected amount of messages in the queue
     * @throws IOException
     */
    public void queueSize(String queue, int expectedCount) throws IOException {
        GetResponse response = channel.basicGet(queue, false);
        if (expectedCount == 0) {
            Assert.assertNull(response);
        } else {
            Assert.assertNotNull(response);
            try {
                Assert.assertEquals(expectedCount, response.getMessageCount()+1);
            } finally {
                channel.basicNack(response.getEnvelope().getDeliveryTag(), false, true);
            }
        }
    }
View Full Code Here

     * @param queue The queue name
     * @param message The message to assert being head of queue
     * @throws IOException
     */
    public void messageInQueue(String queue, String message) throws IOException {
        GetResponse response = channel.basicGet(queue, false);
        Assert.assertNotNull(response);
        try {
            Assert.assertEquals(message, new String(response.getBody(), "UTF-8"));
        } finally {
            channel.basicNack(response.getEnvelope().getDeliveryTag(), false, true);
        }
    }
View Full Code Here

     */
    public void messagesInQueue(String queue, String[] messages) throws IOException {
        long highestDeliveryTag = -1;
        try {
            for (String message : messages) {
                GetResponse response = channel.basicGet(queue, false);
                Assert.assertNotNull(response);
                long deliveryTag = response.getEnvelope().getDeliveryTag();
                highestDeliveryTag = Math.max(highestDeliveryTag, deliveryTag);
                Assert.assertEquals(message, new String(response.getBody(), "UTF-8"));
            }
        } finally {
            if (highestDeliveryTag >= 0) {
                channel.basicNack(highestDeliveryTag, true, true);
            }
View Full Code Here

        channel.queueDeclarePassive(TEST_QUEUE);
       
        String body = "test.body";
        channel.basicPublish(TEST_EXCHANGE, routingKey, new BasicProperties(), body.getBytes());
       
        GetResponse response = channel.basicGet(TEST_QUEUE, true);
        Assert.assertNotNull("no message in queue", response);
        Assert.assertEquals("wrong message in queue", new String(response.getBody(), "UTF-8"), body);
       
        channel.exchangeDelete(TEST_EXCHANGE);
    }
View Full Code Here

        final String queue = (String) parameters[0];
        final boolean autoAck = (Boolean) parameters[1];
        final String clientId = (String) parameters[2];
        final Channel channel = AmqpOperationFactory.this.amqpDriver.getChannel (clientId);
        if (channel != null) {
          GetResponse outcome = null;
          try {
            outcome = channel.basicGet (queue, autoAck);
            if (outcome != null) {
              final Envelope envelope = outcome.getEnvelope ();
              final AMQP.BasicProperties properties = outcome.getProps ();
              message = new AmqpInboundMessage (null, envelope.getDeliveryTag (), envelope.getExchange (), envelope.getRoutingKey (), outcome.getBody (), properties.getDeliveryMode () == 2 ? true : false, properties.getReplyTo (), properties.getContentEncoding (), properties.getContentType (), properties.getCorrelationId (), properties.getMessageId ());
            }
          } catch (final IOException e) {
            AmqpOperationFactory.this.exceptions.traceIgnoredException (e);
          }
        }
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.GetResponse

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.