English 中文(简体)
World 消息在本地主机上被封锁?
原标题:RabbitMQ HelloWorld messages being blocked on localhost?

我用下面的代码 举了一个哈罗世界兔子的榜样:

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.

SO for some reason the rabbitmq server is blocking my connections? Does anyone know what i need to do? Thanks, Ben

最佳回答

检查信件日志, 如 :

=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.neting.rabbittmq.general/16493 以获得更多信息

问题回答

当你看到连接像这样被堵住时, 这意味着您可能超过磁盘和(或)内存的水标记水平。

“http://www.rabbitmq.com/memory.html' rel=“nofollow”>http://www.rabbitmq.com/memory.html 以获得更多信息。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签