【发布时间】:2013-08-25 05:12:08
【问题描述】:
***大家好
我有两台机器,一台是真实的,另一台是Vmware Workstation安装的。它们通过NAT连接
真正的(主机)设置为: IP:192.168.241.1 子网掩码:255.255.255.0 网关IP:192.168.241.2
并且虚拟机设置为: IP:192.168.241.11 子网掩码:255.255.255.0 网关IP:192.168.241.2
我已经在主机和虚拟机上安装了rabbitmq。
我在我的主机上运行这段代码:
ConnectionFactory factorySTC = new ConnectionFactory();
factorySTC.setHost("localhost");
factorySTC.setPort(5672);
Connection connectionSTC = factorySTC.newConnection();
Channel channelSTC = connectionSTC.createChannel();
channelSTC.queueDeclare("queue", true, false, false, null);
String message="helloworld";
channelSTC.basicPublish("","queue",
MessageProperties.PERSISTENT_TEXT_PLAIN,message.getBytes());
我的意思是,我想发送“地狱世界”到队列“队列”
我在我的主机上运行这段代码(上面的 ip 设置为 192.168.241.11):
ConnectionFactory factorySTC = new ConnectionFactory();
factorySTC.setHost("192.168.241.1");
factorySTC.setPort(5672);
Connection connectionSTC = factorySTC.newConnection();
Channel channelSTC = connectionSTC.createChannel();
channelSTC.queueDeclare("queue", true, false, false, null);
QueueingConsumer cosumerSTC=new QueueingConsumer(channelSTC);
QueueingConsumer.Delivery delivery = cosumerSTC.nextDelivery();
String message = new String(delivery.getBody());
但它不起作用。它失败了,并且显示“连接超时....”
那么,如何解决这个问题?我的意思是,我想从安装在与我的电脑在同一个 LAN 中的机器上的 rabbitmq 队列中获取消息...
提前非常非常非常感谢...
问候...
【问题讨论】: