Package com.rabbitmq.client

Examples of com.rabbitmq.client.GetResponse


        for (int i = 0; i < N; i++) {
            basicPublishVolatile(X, K);
        }

        GetResponse response = channel.basicGet(Q, true);
        assertNull("The initial response SHOULD BE null", response);

        deleteQueue(Q);
        deleteExchange(X);
    }
View Full Code Here


        restart();

        basicPublishVolatile("", Q);

        GetResponse response = channel.basicGet(Q, true);
        assertNotNull("The initial response SHOULD NOT be null", response);

        deleteQueue(Q);
    }
View Full Code Here

    }

    public void testFirehose() throws IOException {
        publishGet("not traced");
        enable();
        GetResponse msg = publishGet("traced");
        disable();
        publishGet("not traced");

        GetResponse publish = basicGet(firehose);
        GetResponse deliver = basicGet(firehose);

        assertNotNull(publish);
        assertNotNull(deliver);
        assertDelivered(firehose, 0);

        // We don't test everything, that would be a bit OTT
        checkHeaders(publish.getProps().getHeaders());

        Map<String,Object> delHeaders = deliver.getProps().getHeaders();
        checkHeaders(delHeaders);
        assertNotNull(delHeaders.get("redelivered"));

        assertEquals(msg.getBody().length, publish.getBody().length);
        assertEquals(msg.getBody().length, deliver.getBody().length);
    }
View Full Code Here

                                             getOk.getExchange(),
                                             getOk.getRoutingKey());
            BasicProperties props = (BasicProperties)replyCommand.getContentHeader();
            byte[] body = replyCommand.getContentBody();
            int messageCount = getOk.getMessageCount();
            return new GetResponse(envelope, props, body, messageCount);
        } else if (method instanceof Basic.GetEmpty) {
            return null;
        } else {
            throw new UnexpectedMethodError(method);
        }
View Full Code Here

        Channel channel = connection.createChannel();

        String queue = "ttl.queue";

        // exchange
        GetResponse response = channel.basicGet(queue, false);
        if(response == null) {
            System.out.println("Got no message...");
        } else {
            System.out.println("Got message: " + new String(response.getBody()));
            channel.basicAck(response.getEnvelope().getDeliveryTag(), false);
        }
        channel.close();
        connection.close();
    }
View Full Code Here

        // and immediately fetch it in noack mode
        publishAt(start);
        basicGet(TEST_QUEUE_NAME);
        // publish a 2nd message and immediately fetch it in ack mode
        publishAt(start + TTL * 1 / 2);
        GetResponse r = channel.basicGet(TEST_QUEUE_NAME, false);
        // publish a 3rd message
        publishAt(start + TTL * 3 / 4);
        // reject 2nd message after the initial timer has fired but
        // before the message is due to expire
        waitUntil(start + TTL * 5 / 4);
        channel.basicReject(r.getEnvelope().getDeliveryTag(), true);

        checkPromptArrival(c, 2, latency);
    }
View Full Code Here

    public void rejectionTest(final boolean useNack) throws Exception {
        deadLetterTest(new Callable<Void>() {
                public Void call() throws Exception {
                    for (int x = 0; x < MSG_COUNT; x++) {
                        GetResponse getResponse =
                            channel.basicGet(TEST_QUEUE_NAME, false);
                        long tag = getResponse.getEnvelope().getDeliveryTag();
                        if (useNack) {
                            channel.basicNack(tag, false, false);
                        } else {
                            channel.basicReject(tag, false);
                        }
View Full Code Here

    private static void consumeN(Channel channel, String queue, int n, WithResponse withResponse)
        throws IOException
    {
        for(int x = 0; x < n; x++) {
            GetResponse getResponse =
                channel.basicGet(queue, true);
            assertNotNull("Messages not dead-lettered (" + (n-x) + " left)",
                          getResponse);
            assertEquals("test message", new String(getResponse.getBody()));
            withResponse.process(getResponse);
        }
        GetResponse getResponse = channel.basicGet(queue, true);
        assertNull("expected empty queue", getResponse);
    }
View Full Code Here

     *        to be retrievable from the respective queue
     */
    protected void checkGet(boolean[] expected) throws IOException {
        for (int i = 0; i < resources.length; i++) {
            String q = resources[i];
            GetResponse r = channel.basicGet(q, true);
            assertEquals("check " + q , expected[i], r != null);
        }
    }
View Full Code Here

    private void publish(String payload) throws IOException, InterruptedException {
        basicPublishVolatile(payload.getBytes(), q);
    }

    private void assertHead(int expectedLength, String expectedHeadPayload, String queueName) throws IOException {
        GetResponse head = channel.basicGet(queueName, true);
        if (expectedLength > 0) {
            assertNotNull(head);
            assertEquals(expectedHeadPayload, new String(head.getBody()));
            assertEquals(expectedLength, head.getMessageCount() + 1);
        } else {
            assertNull(head);
        }
    }
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.