Package com.rabbitmq.client

Examples of com.rabbitmq.client.Envelope


    final ConsumerDelegate consumerDelegate = (ConsumerDelegate) invocation.args[invocation.args.length - 1];
    new Thread() {
      public void run() {
        try {
          for (; deliveryTag.get() <= 100000 && consume.get(); deliveryTag.incrementAndGet()) {
            consumerDelegate.handleDelivery("test-tag", new Envelope(deliveryTag.get(), false, "x",
                "#"), null, ("foo-" + deliveryTag).getBytes());
            Thread.sleep(5);
          }
        } catch (Exception e) {
        }
View Full Code Here


    long deliveryTag = envelope.getDeliveryTag();
    channelHandler.maxDeliveryTag = deliveryTag = deliveryTag
        + channelHandler.previousMaxDeliveryTag;
    delegate.handleDelivery(
        consumerTag,
        new Envelope(deliveryTag, envelope.isRedeliver(), envelope.getExchange(),
            envelope.getRoutingKey()), properties, body);
  }
View Full Code Here

    @Test
    public void testHandleDelivery() throws IOException {
        MockConsumer consumer = new MockConsumer();

        String consumerTag = "1";
        Envelope envelope = new Envelope(1l, false, "exchange", "routingKey");
        BasicProperties props = create();
        byte[] body = new byte[25];
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
        consumer.handleDelivery(consumerTag, envelope, props, body);
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
View Full Code Here

    }

    @Test
    public void testBasicGet() throws IOException {

        Envelope envelope = new Envelope(1l, false, "exchange", "routingKey");
        BasicProperties props = create();
        byte[] body = new byte[25];

        MockChannel channel = new MockChannel(envelope, props, body);
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
View Full Code Here

            QueueingConsumer consumer = new QueueingConsumer(channel);
            channel.basicConsume(queue, consumer);
            while (true) {
                QueueingConsumer.Delivery delivery = consumer.nextDelivery();
                Envelope envelope = delivery.getEnvelope();
                System.out.println(envelope.getRoutingKey() + ": " + new String(delivery.getBody()));
                channel.basicAck(envelope.getDeliveryTag(), false);
            }
        } catch (Exception ex) {
            System.err.println("Main thread caught exception: " + ex);
            ex.printStackTrace();
            System.exit(1);
View Full Code Here

                    else {
                        callback = defaultConsumer;
                    }
                }

                Envelope envelope = new Envelope(m.getDeliveryTag(),
                                                 m.getRedelivered(),
                                                 m.getExchange(),
                                                 m.getRoutingKey());
                try {
                    this.dispatcher.handleDelivery(callback,
View Full Code Here

                                                 .build());
        Method method = replyCommand.getMethod();

        if (method instanceof Basic.GetOk) {
            Basic.GetOk getOk = (Basic.GetOk)method;
            Envelope envelope = new Envelope(getOk.getDeliveryTag(),
                                             getOk.getRedelivered(),
                                             getOk.getExchange(),
                                             getOk.getRoutingKey());
            BasicProperties props = (BasicProperties)replyCommand.getContentHeader();
            byte[] body = replyCommand.getContentBody();
View Full Code Here

                    DataInputStream d = new DataInputStream(new ByteArrayInputStream(delivery.getBody()));
                    d.readInt();
                    long msgNano = d.readLong();
                    long nano = System.nanoTime();

                    Envelope envelope = delivery.getEnvelope();

                    if (!autoAck) {
                        if (multiAckEvery == 0) {
                            channel.basicAck(envelope.getDeliveryTag(), false);
                        } else if (totalMsgCount % multiAckEvery == 0) {
                            channel.basicAck(envelope.getDeliveryTag(), true);
                        }
                    }

                    if (txSize != 0 && totalMsgCount % txSize == 0) {
                        channel.txCommit();
                    }

                    now = System.currentTimeMillis();

                    stats.handleRecv(id.equals(envelope.getRoutingKey()) ? (nano - msgNano) : 0L);
                }

            } catch (IOException e) {
                throw new RuntimeException(e);
            } catch (InterruptedException e) {
View Full Code Here

            else {
                callback = defaultConsumer;
            }
        }

        Envelope envelope = new Envelope(m.getDeliveryTag(),
                                         m.getRedelivered(),
                                         m.getExchange(),
                                         m.getRoutingKey());
        try {
            this.dispatcher.handleDelivery(callback,
View Full Code Here

                                                 .build());
        Method method = replyCommand.getMethod();

        if (method instanceof Basic.GetOk) {
            Basic.GetOk getOk = (Basic.GetOk)method;
            Envelope envelope = new Envelope(getOk.getDeliveryTag(),
                                             getOk.getRedelivered(),
                                             getOk.getExchange(),
                                             getOk.getRoutingKey());
            BasicProperties props = (BasicProperties)replyCommand.getContentHeader();
            byte[] body = replyCommand.getContentBody();
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.Envelope

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.