[rabbitmq-discuss] RabbitMq Tutorial One cannot work under CentOS5.5

johnson johnson at edocom.cn
Thu May 3 10:28:36 BST 2012


Hi guys,

I am quite new to RabbitMq and now try to learn it from the tutorial. I installed the windows version and the LINUX version (CentOS 5.5) of RabbitMQ 2.8.2. The Erlang version is R14B03 in Linux. In Windows, everything is fine. But in CENTOS5.5, after sending the message, the program cannot exit and always stuck. Hence, the receiver also cannot get the message. Can you point out how to debug it? Thanks a lot!

http://www.rabbitmq.com/tutorials/tutorial-one-java.html

import com.rabbitmq.client.ConnectionFactory;import com.rabbitmq.client.Connection;import com.rabbitmq.client.Channel;public class Send {  private final static String QUEUE_NAME = "hello";  public static void main(String[] argv) throws Exception {      	          ConnectionFactory factory = new ConnectionFactory();    factory.setHost("localhost");    Connection connection = factory.newConnection();    Channel channel = connection.createChannel();    channel.queueDeclare(QUEUE_NAME, false, false, false, null);    String message = "Hello World!";    channel.basicPublish("", QUEUE_NAME, null, message.getBytes());    System.out.println(" [x] Sent '" + message + "'");        channel.close();    connection.close();  }}import com.rabbitmq.client.ConnectionFactory;import com.rabbitmq.client.Connection;import com.rabbitmq.client.Channel;import com.rabbitmq.client.QueueingConsumer;public class Recv {    private final static String QUEUE_NAME = "hello";    public static void main(String[] argv) throws Exception {    ConnectionFactory factory = new ConnectionFactory();    factory.setHost("localhost");    Connection connection = factory.newConnection();    Channel channel = connection.createChannel();    channel.queueDeclare(QUEUE_NAME, false, false, false, null);    System.out.println(" [*] Waiting for messages. To exit press CTRL+C");        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 + "'");    }  }}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120503/6100e380/attachment.htm>


More information about the rabbitmq-discuss mailing list