Skip to content

Instantly share code, notes, and snippets.

@liubin
Created September 3, 2013 09:29
Show Gist options
  • Save liubin/6421628 to your computer and use it in GitHub Desktop.
Save liubin/6421628 to your computer and use it in GitHub Desktop.
public void loop() throws java.io.IOException,
java.lang.InterruptedException {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("192.168.11.232");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, true, consumer);
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(" [x] Received '" + message + "'");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment