Examples of basicAck()


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

      QueueingConsumer.Delivery delivery = consumer.nextDelivery();
      String message = new String(delivery.getBody());
      System.out.println(" [x] Received '" + message + "'");
      doWork(message);
      System.out.println(" [x] Done");
      channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
    }
  }

  private static void doWork(String task) throws InterruptedException {
    for (char ch : task.toCharArray()) {
View Full Code Here

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

          System.out.println(" [.] " + e.toString());
          response = "";
        } finally {
          channel.basicPublish("", props.getReplyTo(), replyProps,
              response.getBytes("UTF-8"));
          channel.basicAck(delivery.getEnvelope().getDeliveryTag(),
              false);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

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

           
            byte[] bobyByte = delivery.getBody();
            String bodyStr = new String(bobyByte, this.getEncoding());//"US-ASCII", "utf-8"
           
          if(dispatchJob(this.getName(), bodyStr)) {
            channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
           
            completedJobs.incrementAndGet();
            _logger.info("ack meg:" + delivery.getEnvelope().getDeliveryTag());
          } else {
            channel.basicReject(delivery.getEnvelope().getDeliveryTag(), true);
View Full Code Here

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

          {
            try {
              log.info("Acknowledging delivery of messages up to tag: " + deliveryTag);

              // Acknowledge all messages up to and including the stored delivery tag.
              channel.basicAck(deliveryTag, true);
            }
            catch (IOException e) {
              log.error(e, "Unable to acknowledge message reception to message queue.");
            }
          }
View Full Code Here

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

     
      System.out.println(" [x] Received '" + message + "'");
      doWork(message);
      System.out.println(" [x] Done");

      channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
    }        
  }
 
  private static void doWork(String task) throws InterruptedException {
    for (char ch: task.toCharArray()) {
View Full Code Here

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

          response = "";
        }
        finally
          channel.basicPublish( "", props.getReplyTo(), replyProps, response.getBytes("UTF-8"));
 
          channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
        }
      }
    }
    catch  (Exception e) {
      e.printStackTrace();
View Full Code Here

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

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

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

            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

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

        FileOutputStream o = new FileOutputStream(f);
        o.write(body);
        o.close();
        System.out.println(" done.");
    }
    ch.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
            }
        } catch (Exception ex) {
            System.err.println("Main thread caught exception: " + ex);
            ex.printStackTrace();
            System.exit(1);
View Full Code Here

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

        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
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.