Examples of basicConsume()


Examples of com.rabbitmq.client.Channel.basicConsume()

    Channel channel = connection.createChannel();
    channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);
    System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
    channel.basicQos(1);
    QueueingConsumer consumer = new QueueingConsumer(channel);
    channel.basicConsume(TASK_QUEUE_NAME, false, consumer);
    while (true) {
      QueueingConsumer.Delivery delivery = consumer.nextDelivery();
      String message = new String(delivery.getBody());
      System.out.println(" [x] Received '" + message + "'");
      doWork(message);
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

      connection = factory.newConnection();
      channel = connection.createChannel();
      channel.queueDeclare(RPC_QUEUE_NAME, false, false, false, null);
      channel.basicQos(1);
      QueueingConsumer consumer = new QueueingConsumer(channel);
      channel.basicConsume(RPC_QUEUE_NAME, false, consumer);
      System.out.println(" [x] Awaiting RPC requests");
      while (true) {
        String response = null;
        QueueingConsumer.Delivery delivery = consumer.nextDelivery();
        BasicProperties props = delivery.getProperties();
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

        channel.queueBind(queueName, EXCHANGE_NAME, bindingKey);
      }
      System.out
          .println(" [*] Waiting for messages. To exit press CTRL+C");
      QueueingConsumer consumer = new QueueingConsumer(channel);
      channel.basicConsume(queueName, true, consumer);
      while (true) {
        QueueingConsumer.Delivery delivery = consumer.nextDelivery();
        String message = new String(delivery.getBody());
        String routingKey = delivery.getEnvelope().getRoutingKey();
        System.out.println(" [x] Received '" + routingKey + "':'"
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

        final List<Envelope> received = new ArrayList<Envelope>();

        Channel channel = conn.createChannel();
        channel.queueDeclare("sammyq", false, false, true, null);
        channel.queueBind("sammyq", EXCHANGE, "route1");
        channel.basicConsume("sammyq", true, new DefaultConsumer(channel) {
            @Override
            public void handleDelivery(String consumerTag,
                                       Envelope envelope,
                                       AMQP.BasicProperties properties,
                                       byte[] body) throws IOException {
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

      channel.queueDeclare(queueName, durable, exclusive, autoDelete, null);
      channel.queueBind(queueName, exchangeName, routingKey);
     
      boolean autoAck = false;
      QueueingConsumer consumer = new QueueingConsumer(channel);
      channel.basicConsume(queueName, autoAck, consumer);
     
      boolean run = true;
      while (run) {
        final ReentrantLock runLock = this.runLock;
              runLock.lock();
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

    );

    // We create a QueueingConsumer that will not auto-acknowledge messages since that
    // happens on commit().
    final QueueingConsumer consumer = new QueueingConsumer(channel);
    channel.basicConsume(queue, false, consumer);

    return new Firehose()
    {
      /**
       * Storing the latest delivery as a member variable should be safe since this will only be run
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

    public void testConsumeFail() throws IOException, InterruptedException {
        QueueingConsumer c = new QueueingConsumer(channel);
        Channel ch = connection.createChannel();
        try {
            ch.basicConsume(QUEUE, false, c);
        } catch (IOException e) {
            // Can't have ack mode
            checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
        }
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

            // Can't have ack mode
            checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
        }

        ch = connection.createChannel();
        ch.basicConsume(QUEUE, true, c);
        try {
            ch.basicConsume(QUEUE, true, c);
        } catch (IOException e) {
            // Can't have multiple consumers
            checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

        }

        ch = connection.createChannel();
        ch.basicConsume(QUEUE, true, c);
        try {
            ch.basicConsume(QUEUE, true, c);
        } catch (IOException e) {
            // Can't have multiple consumers
            checkShutdownSignal(AMQP.PRECONDITION_FAILED, e);
        }
    }
View Full Code Here

Examples of com.rabbitmq.client.Channel.basicConsume()

        assertEquals(cf.getExceptionHandler(), eh);
        Connection conn = cf.newConnection();
        assertEquals(conn.getExceptionHandler(), eh);
        Channel ch = conn.createChannel();
        String q = ch.queueDeclare().getQueue();
        ch.basicConsume(q, new DefaultConsumer(ch) {
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                throw new RuntimeException("oops");
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.