Examples of QueueingConsumer


Examples of com.rabbitmq.client.QueueingConsumer

    private void assertFailValidation(Map<String, Object> args) throws IOException {
        Channel ch = connection.createChannel();
        String queue = ch.queueDeclare().getQueue();
        try {
            ch.basicConsume(queue, true, args, new QueueingConsumer(ch));
            fail("Validation should fail for " + args);
        } catch (IOException ioe) {
            checkShutdownSignal(AMQP.PRECONDITION_FAILED, ioe);
        }
    }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    private static final int COUNT = 10;

    public void testConsumerPriorities() throws Exception {
        String queue = channel.queueDeclare().getQueue();
        QueueingConsumer highConsumer = new QueueingConsumer(channel);
        QueueingConsumer medConsumer = new QueueingConsumer(channel);
        QueueingConsumer lowConsumer = new QueueingConsumer(channel);
        String high = channel.basicConsume(queue, true, args(1), highConsumer);
        String med = channel.basicConsume(queue, true, medConsumer);
        channel.basicConsume(queue, true, args(-1), lowConsumer);

        publish(queue, COUNT, "high");
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    channel.exchangeDeclare("rpc", "direct");
    channel.queueDeclare("ping", false, false, false, null);
    channel.queueBind("ping", "rpc", "ping");

    consumer = new QueueingConsumer(channel);
    channel.basicConsume("ping", false, "ping", consumer);

    System.out.println(
      "Waiting for RPC calls..."
    );
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

  }

  public Client setupConsumer()
  throws Exception {
    replyQueueName = channel.queueDeclare().getQueue();
    consumer = new QueueingConsumer(channel);
    channel.basicConsume(replyQueueName, false, consumer);
    return this;
  }
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();

            //  Establish the REQ/REP wiring.
            String queueName = channel.queueDeclare().getQueue();
            QueueingConsumer consumer = new QueueingConsumer(channel);
            channel.basicConsume(queueName, true, consumer);

            //  Send the request
            AMQP.BasicProperties properties = new AMQP.BasicProperties();
            properties.setReplyTo(queueName);
            channel.basicPublish("", "REQREP", properties,
                "Hello!".getBytes());

            //  Get and print the reply
            QueueingConsumer.Delivery delivery = consumer.nextDelivery();
            String reply = new String(delivery.getBody());
            System.out.println(reply);

            connection.close();
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

            Channel channel = connection.createChannel();

            //  Establish the PUB/SUB wiring
            String queueName = channel.queueDeclare().getQueue();
            channel.queueBind(queueName, "PIPELINE", null);
            QueueingConsumer consumer = new QueueingConsumer(channel);
            channel.basicConsume(queueName, true, consumer);

            for (;;) {

                //  Get next request
                String msg = consumer.nextDelivery().getBody().toString();
                System.out.println (msg);
            }
        } catch (Exception e) {
            System.err.println("Main thread caught exception: " + e);
            e.printStackTrace();
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();

            //  Establish the REQ/REP wiring.
            channel.queueDeclare("REQREP", true, false, false, null);
            QueueingConsumer consumer = new QueueingConsumer(channel);
            channel.basicConsume("REQREP", true, consumer);

            for (;;) {

                //  Get next request
                QueueingConsumer.Delivery delivery = consumer.nextDelivery();
                String replyTo = delivery.getProperties().getReplyTo();
                String correlationId = delivery.getProperties().getCorrelationId();

                BasicProperties props =
                  (BasicProperties) (delivery.getProperties().clone());
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

            Channel channel = connection.createChannel();

            //  Establish the PUB/SUB wiring
            String queueName = channel.queueDeclare().getQueue();
            channel.queueBind(queueName, "PUBSUB", null);
            QueueingConsumer consumer = new QueueingConsumer(channel);
            channel.basicConsume(queueName, true, consumer);

            for (;;) {

                //  Get next request
                String msg = consumer.nextDelivery().getBody().toString();
                System.out.println (msg);
            }
        } catch (Exception e) {
            System.err.println("Main thread caught exception: " + e);
            e.printStackTrace();
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

    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);
      System.out.println(" [x] Done");
View Full Code Here

Examples of com.rabbitmq.client.QueueingConsumer

      channel.queueBind(queueName, EXCHANGE_NAME, severity);
    }
   
    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 + "':'" + message + "'");  
    }
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.