Package com.rabbitmq.client

Examples of com.rabbitmq.client.GetResponse


        channel.basicReject(d.getEnvelope().getDeliveryTag(), true);
        assertNull(c.nextDelivery(100));
    }

    private String get() throws IOException {
        GetResponse response = basicGet(TTL_QUEUE_NAME);
        return response == null ? null : new String(response.getBody());
    }
View Full Code Here


        Map<String, Object> argMap = Collections.singletonMap(TTL_ARG, ttlValue);
        return this.channel.queueDeclare(name, false, true, false, argMap);
    }

    private void expectBodyAndRemainingMessages(String body, int messagesLeft) throws IOException {
        GetResponse response = channel.basicGet(TTL_QUEUE_NAME, false);
        assertEquals(body, new String(response.getBody()));
        assertEquals(messagesLeft,  response.getMessageCount());
    }
View Full Code Here

        byte[] testDataBody = "test-data".getBytes();

        // We should be able to publish to the non-internal exchange as usual
        // and see our message land in the queue...
        channel.basicPublish("e0", "", null, testDataBody);
        GetResponse r = channel.basicGet("q1", true);
        assertTrue(Arrays.equals(r.getBody(), testDataBody));

        // Publishing to the internal exchange will not be allowed...
        channel.basicPublish("e1", "", null, testDataBody);

        expectError(AMQP.ACCESS_REFUSED);
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();
            Thread.sleep(GRATUITOUS_DELAY);
            open();
            GetResponse r2 = getMessage();
            if (doAck && r2 != null) {
                fail("Expected missing second basicGet (repeat="+repeat+")");
            } else if (!doAck && r2 == null) {
                fail("Expected present second basicGet (repeat="+repeat+")");
            }
View Full Code Here

        channel.basicConsume(Q, c);
        c.nextDelivery();
        close();
        open();
        for (int i = 0; i < MESSAGE_COUNT; i++) {
            GetResponse r = channel.basicGet(Q, true);
            assertNotNull("only got " + i + " out of " + MESSAGE_COUNT +
                          " messages", r);
        }
        assertNull(channel.basicGet(Q, true));
        channel.queueDelete(Q);
View Full Code Here

        Queue<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

    public void testSSL() throws IOException
    {
        channel.queueDeclare("Bug19356Test", false, true, true, null);
        channel.basicPublish("", "Bug19356Test", null, "SSL".getBytes());

        GetResponse chResponse = channel.basicGet("Bug19356Test", false);
        assertNotNull(chResponse);

        byte[] body = chResponse.getBody();
        assertEquals("SSL", new String(body));
    }
View Full Code Here

        propsBuilder.headers(headers);
        channel.basicPublish(ex, to, propsBuilder.build(), new byte[0]);
    }

    private void expect(String[] expectedQueues, boolean usedCc) throws IOException {
        GetResponse getResponse;
        List<String> expectedList = Arrays.asList(expectedQueues);
        for (String q : queues) {
            getResponse = basicGet(q);
            if (expectedList.contains(q)) {
                assertNotNull(getResponse);
                assertEquals(0, getResponse.getMessageCount());
                Map<?, ?> headers = getResponse.getProps().getHeaders();
                if (headers != null){
                    assertEquals(usedCc, headers.containsKey("CC"));
                    assertFalse(headers.containsKey("BCC"));
                }
            } else {
View Full Code Here

        int remaining = batchSize;
        int count = 0;

        while (notEmpty && (remaining > 0)) {
            for (int i = 0; (i < 2) && (remaining > 0); i++) {
                GetResponse c = _ch1.basicGet(queueName, autoAck);
                if (c == null) {
                    notEmpty = false;
                } else {
                    String msg = new String(c.getBody());
                    log("Got message (" + c.getMessageCount() + " left in q): " + msg);
                    latestTag = c.getEnvelope().getDeliveryTag();
                    remaining--;
                    count++;
                }
            }
            if (!autoAck && latestTag != 0) {
View Full Code Here

    protected void assertDelivered(String q, int count) throws IOException {
        assertDelivered(q, count, false);
    }

    protected void assertDelivered(String q, int count, boolean redelivered) throws IOException {
        GetResponse r;
        for (int i = 0; i < count; i++) {
            r = basicGet(q);
            assertNotNull(r);
            assertEquals(redelivered, r.getEnvelope().isRedeliver());
        }
        assertNull(basicGet(q));
    }
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.