-
1. Re: Multicast communication does not work with Stand-alone cluster
gaohoward Dec 12, 2011 10:23 PM (in response to fastbucks)If you can upload a test, that'll be a great help for us to investigate it.
Howard
-
2. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 12:42 AM (in response to gaohoward)All I am doing is very simple. I have 3 machines A, B, and C. On A, I have the HornetQ client running the (partial) code I posted in my original post. Of course there is code for posting messages etc. Machines B and C have stand-alone clustered HornetQ nodes. UDP is enabled for all of them. The client on machine A creates a connection with the multicast address for B and C as follows:
connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(
new DiscoveryGroupConfiguration(231.7.7.7, 9876), JMSFactoryType.CF);
connectionFactory.setReconnectAttempts(-1);
connectionFactory.getDiscoveryGroupConfiguration().setDiscoveryInitialWaitTimeout(100000);
try {
jmsConnection = (HornetQConnection) connectionFactory.createConnection(userName, pwd);
session = (HornetQSession) jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (JMSException je) {
logger.error("JMS issue with the HornetQ artifacts.", je);
}
The client hangs when it tries to create the connection from the connectionFactory and times out. I am running HornetQ 2.2.5.Final. The thread in DiscoveryGroupImpl.java at line 307, is trying to join the multicast group with socket.receive(packet);. For whatever reason, it is not able to join. Obviously, the waitForBroadcast() method times out.
Now, I wrote a simple java client to join the multicast group and another client to send a message to the group. With the same multicast IP address that I mentioned above, the java clients work perfectly fine joining the group, sending message, and getting the message. Not sure why the thread in DiscoveryGroupImpl is not able to join the multicast group.
-
3. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 13, 2011 2:57 AM (in response to fastbucks)I think this has ben discussed several times in the forums, however see http://community.jboss.org/wiki/RunningAHornetQClusterUsingDiscoveryDoesntWork
-
4. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 10:12 AM (in response to ataylor)I checked the link http://community.jboss.org/wiki/RunningAHornetQClusterUsingDiscoveryDoesntWork but the scenarios do not seem to apply to my case. As I mentioned in my earlier post, I have these two utilities that I am pasting below. I run the JoinHornetQ to join the multicast group and PingHornetQ to send a message to the multicast group. When I run these classes with the HornetQ cluster that I am having problem with all machines remaining the same, the java clients work as expected.
JoinHornetQ.java
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
public class JoinHornetQ {
/**
* @param args
*/
public static void main(String[] args) {
String groupName = "232.7.7.7";
int port = 9872;
receivePackets(groupName, port);
}
private static void receivePackets(String groupName, int port) {
try {
MulticastSocket socket = new MulticastSocket(port);
InetAddress groupAddress = InetAddress.getByName(groupName);
socket.joinGroup(groupAddress);
DatagramPacket packet;
for (int i = 0; i < 50000; i++) {
byte[] buf = new byte[1024];
packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
String received = new String(packet.getData());
System.out.println("Data received: " + received);
}
socket.leaveGroup(groupAddress);
socket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
PingHornetQ.java
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
public class PingHornetQ {
/**
* @param args
*/
public static void main(String[] args) {
int port = 9872;
String groupName = "232.7.7.7";
sendMessage(groupName, port);
}
private static void sendMessage(String groupName, int port) {
byte[] outbuf = new byte[1024];
outbuf = "This will be great, iA".getBytes();
try {
DatagramSocket socket = new DatagramSocket();
InetAddress broadcastAddress = InetAddress.getByName(groupName);
DatagramPacket packet = new DatagramPacket(outbuf, outbuf.length, broadcastAddress, port);
socket.send(packet);
} catch (Exception e) {
e.printStackTrace();
}
}
}
-
5. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 13, 2011 10:22 AM (in response to fastbucks)I dont really gwet what your client is, its not HornetQ! If the socket.receive(packet) is not working its becasue either UDp isnt enabled on the cluster or you dont have a loopback address when they are all on the same machine. Either that or your UDP config is wrong. This is not really hornetq code.
I would start by making sure the excamplesd work, then if you find an issue prepare us a test we can easily run.
-
6. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 10:45 AM (in response to ataylor)What I am basically saying is that the HornetQ cluster is the same (two HornetQ stand-alone nodes on two separate machine). Now, on a third machine, instead of running my HornetQ client, I am running the sample java files I posted. These sample java files are able to join the multicast group of HornetQ nodes and also send packets to the group. Hope that clarifies what I am trying to do.
As for the examples, they run on the same machine. I would not be able to test them with the topology I am working.
-
7. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 13, 2011 10:54 AM (in response to ataylor)can you post all your config, thats all i can think can be wrong
-
8. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 1:32 PM (in response to ataylor)Please find the configuration files attached. Do you see anything wrong? Appreciate any input. Thanks.
-
hornetq-jms.xml 1.8 KB
-
hornetq-configuration.xml 3.8 KB
-
hornetq-beans.xml 2.0 KB
-
-
9. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 5:06 PM (in response to fastbucks)The interesting thing is if I have a one node stand-alone cluster on my local machine, it works. Only when the cluster is on different machine(s), HornetQ client is not receiving packets.
-
10. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 13, 2011 6:19 PM (in response to fastbucks)I am trying TransportConfiguration instead of DiscoveryGroupConfiguration but that does not seem to work either. I do not have firewall enabled on any server. Appreciate any help.
-
11. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 14, 2011 2:49 AM (in response to fastbucks)make sure that you are binding the acceptors and connectors to a reachable addreess, i.e. not localhost which is the default in your configuration.
-
12. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 14, 2011 2:52 AM (in response to ataylor)also your test program is using a different port so I''m not sure how it can receive anythuing from another node, maybe its receiving its own broadcast. Again make sure UDP is enabled on the network.
-
13. Re: Multicast communication does not work with Stand-alone cluster
fastbucks Dec 14, 2011 6:25 PM (in response to ataylor)The acceptors and connectors have the right ip address in my deployment. Now, I connected the debugger to HornetQ server. The debugger gets stuck in BroadcastGroupImpl start() method at this line:
started = true;
It is line 129. Not sure what is happening at that point. I am not providing local bind address and port. Keeping it default. Ideas?
-
14. Re: Multicast communication does not work with Stand-alone cluster
ataylor Dec 15, 2011 2:52 AM (in response to fastbucks)That cant be happening, there is no syncronisation there and its a simple line of code