【问题标题】:RabbitMQ HelloWorld messages being blocked on localhost?RabbitMQ HelloWorld 消息在本地主机上被阻止?
【发布时间】:2012-05-25 10:52:15
【问题描述】:

我一直在运行 hello world RabbitMQ 示例,代码如下:

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 java.io.IOException {
        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 java.io.IOException,
                 java.lang.InterruptedException {

          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 + "'");
         }
    }
}

当我运行接收器时,它会侦听队列,发送器说它正在发送消息,但似乎没有关闭。然后我运行:

rabbitmqctl list_queues

队列肯定正在创建中。

但是当我跑步时:

rabbitmqctl list_connections

我得到以下输出

benuni@DeShawn:~$ sudo rabbitmqctl list_connections
ls: cannot access /etc/rabbitmq/rabbitmq.conf.d: No such file or directory
Listing connections ...
guest   127.0.0.1   64700   blocked
guest   127.0.0.1   64709   blocked
guest   127.0.0.1   64614   blocked
guest   127.0.0.1   64716   blocked
guest   127.0.0.1   64717   blocked
guest   127.0.0.1   64701   blocked
guest   127.0.0.1   64699   blocking
guest   127.0.0.1   64613   blocking
guest   127.0.0.1   64708   blocking
guest   127.0.0.1   64718   blocked
guest   127.0.0.1   64706   blocked
...done.

所以由于某种原因,rabbitmq 服务器阻止了我的连接? 有谁知道我需要做什么? 谢谢, 本

【问题讨论】:

    标签: java message rabbitmq mq


    【解决方案1】:

    检查日志中的以下消息:

    =INFO REPORT==== 2-Jul-2012::13:38:02 ===
    Disk free space limit now exceeded. Free bytes:13114646528 Limit:15740784640
    

    更多信息请见http://comments.gmane.org/gmane.comp.networking.rabbitmq.general/16493

    【讨论】:

    • 谢谢,我忘记了这篇文章。这就是最终的问题。应该自己更新
    【解决方案2】:

    当您看到这样的连接被阻塞时,这意味着您可能超出了磁盘和/或内存的水印级别。

    请参阅:http://www.rabbitmq.com/memory.html 了解更多信息。

    【讨论】:

      猜你喜欢
      • 2022-01-18
      • 2017-02-09
      • 1970-01-01
      • 1970-01-01
      • 2013-07-03
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 2019-11-17
      相关资源
      最近更新 更多