ch.queueDeclare(queueName, false, false, false, null);
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);