Package com.rabbitmq.client

Examples of com.rabbitmq.client.Envelope


            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


            {
                logger.fine(body.encode());
            }
        };

        Envelope envelope = new Envelope(42L, false, "", "whatever");
        AMQP.BasicProperties props = new AMQP.BasicProperties.Builder()
            .contentType("application/bson")
            .build();

        consumer.handleDelivery(null, envelope, props, bsonData);
View Full Code Here

        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

    container.setChannelTransacted(true);
    container.setShutdownTimeout(100);
    container.afterPropertiesSet();
    container.start();

    consumer.get().handleDelivery("qux", new Envelope(1, false, "foo", "bar"), new BasicProperties(), new byte[] {0});

    assertTrue(latch.await(10, TimeUnit.SECONDS));

    Exception e = tooManyChannels.get();
    if (e != null) {
View Full Code Here

    container.setChannelTransacted(true);
    container.setShutdownTimeout(100);
    container.afterPropertiesSet();
    container.start();

    consumer.get().handleDelivery("qux", new Envelope(1, false, "foo", "bar"), new BasicProperties(), new byte[] {0});

    assertTrue(latch.await(10, TimeUnit.SECONDS));

    Exception e = tooManyChannels.get();
    if (e != null) {
View Full Code Here

    container.setExposeListenerChannel(false);
    container.setShutdownTimeout(100);
    container.afterPropertiesSet();
    container.start();

    consumer.get().handleDelivery("qux", new Envelope(1, false, "foo", "bar"), new BasicProperties(), new byte[] {0});

    assertTrue(latch.await(10, TimeUnit.SECONDS));

    Exception e = tooManyChannels.get();
    if (e != null) {
View Full Code Here

      }
    });
    container.start();
    BasicProperties props = new BasicProperties();
    byte[] payload = "baz".getBytes();
    Envelope envelope = new Envelope(1L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    envelope = new Envelope(2L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    envelope = new Envelope(3L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    envelope = new Envelope(4L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    assertTrue(latch.await(5, TimeUnit.SECONDS));
    assertEquals(4, messages.size());
    Executors.newSingleThreadExecutor().execute(new Runnable() {
View Full Code Here

      }
    });
    container.start();
    BasicProperties props = new BasicProperties();
    byte[] payload = "baz".getBytes();
    Envelope envelope = new Envelope(1L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    envelope = new Envelope(2L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    envelope = new Envelope(3L, false, "foo", "bar");
    consumer.get().handleDelivery("1", envelope, props, payload);
    assertTrue(latch.await(5, TimeUnit.SECONDS));
    assertEquals(3, messages.size());
    Executors.newSingleThreadExecutor().execute(new Runnable() {
View Full Code Here

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

          Envelope envelope = delivery.getEnvelope();

          if (!autoAck) {
            channel.basicAck(envelope.getDeliveryTag(), false);
          }

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

          now = System.currentTimeMillis();

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

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

    container.setShutdownTimeout(100);
    container.setTransactionManager(new DummyTxManager());
    container.afterPropertiesSet();
    container.start();

    consumer.get().handleDelivery("qux", new Envelope(1, false, "foo", "bar"), new BasicProperties(), new byte[] {0});

    assertTrue(latch.await(10, TimeUnit.SECONDS));

    Exception e = tooManyChannels.get();
    if (e != null) {
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.