0

***Hi,all

I have two machines.One is real and the other one is installed by Vmware Workstation。They connect via NAT

The real one(host machine) was set to: IP:192.168.241.1 Subnetmask:255.255.255.0 gateway IP:192.168.241.2

and the virtual machine was set to: IP:192.168.241.11 Subnetmask:255.255.255.0 gateway IP:192.168.241.2

and I have installed rabbitmq both in host machine and viratual machine.

I run this code in my host machine:

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());

I mean,i want to send "hellworld" to queue "queue"

and I run this code in my host machine(whose ip was set to 192.168.241.11 above):

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());

but it does not work.It failed and something shows that"connect timed out...."

so,how to solve this problem?I mean,i want to get message from the rabbitmq queues which are installed in machines which are in the same LAN with my pc...

thanks very very very much in advance...

Regards...

4

1 に答える 1

0

2 台目のマシンに rabbitmq サーバーをインストールする必要はありません。全体的なポイントは、1 つのサーバーと他のすべてのマシンがキュー/交換に発行し、1 つのサーバーのキューから読み取ることです。次に、接続タイムアウトが発生している場合は、ネットワークに問題があり、ファイアウォールの問題である可能性が最も高いです。

于 2013-08-22T13:21:39.840 に答える