Created
September 3, 2013 09:29
-
-
Save liubin/6421628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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