HornetQ with JGroups
realkobe Jun 8, 2015 6:39 AMHi,
I want to configure HornetQ to use JGroups and use it in my Java Client. Unfortunetaly I don't find a working example for my client.
I took the jgroups configuration from Chapter 38. Clusters and adjusted
<FILE_PING location="/tmp/file.ping.dir"/>
The server starts and opens some ports, probably port 7500 is for Jgroups
~> netstat -tulpen 2> /dev/null | grep java tcp6 0 0 :::62500 :::* LISTEN 1000 2081291 9255/java tcp6 0 0 :::62501 :::* LISTEN 1000 2081273 9255/java tcp6 0 0 127.0.0.1:43909 :::* LISTEN 1000 945698 2488/java tcp6 0 0 :::62502 :::* LISTEN 1000 2081205 9255/java tcp6 0 0 :::62503 :::* LISTEN 1000 2081204 9255/java tcp6 0 0 :::46029 :::* LISTEN 1000 2081185 9255/java tcp6 0 0 fe80::4538:3b62:c:52464 :::* LISTEN 1000 2081292 9255/java tcp6 0 0 fe80::4538:3b62:c:57600 :::* LISTEN 1000 2082278 9255/java udp6 0 0 :::7500 :::* 1000 2081293 9255/java
But how to connect?
Create a DiscoveryGroup (no clue about the parameters)
private DiscoveryGroupConfiguration getGroupConfiguration() { String name = "name"; String localBindAddress = "localhost"; String groupAddress = "localhost"; int groupPort = 7500; long refreshTimeout = 1000; long discoveryInitialWaitTimeout = 1000; return new DiscoveryGroupConfiguration(name, localBindAddress, groupAddress, groupPort, refreshTimeout, discoveryInitialWaitTimeout); }
Create a connection factory
private HornetQConnectionFactory createDiscoveryGroupFactory() { HornetQConnectionFactory factory = HornetQJMSClient.createConnectionFactoryWithHA getGroupConfiguration(), JMSFactoryType.CF); return factory; }
Move into JMS world by creating a JMS connection
public Connection createConnection() throws JMSException { return createFactory().createConnection(); }
This code does *not* work, it produces
Failed to create discovery group socket
java.net.SocketException: Not a multicast address
at java.net.MulticastSocket.joinGroup(MulticastSocket.java:310)
at org.hornetq.core.cluster.impl.DiscoveryGroupImpl.start(DiscoveryGroupImpl.java:126)
at org.hornetq.core.client.impl.ServerLocatorImpl.initialise(ServerLocatorImpl.java:338)
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:553)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:611)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:121)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)
I also tried with JGroupsBroadcastGroupConfiguration (from hornetq-core-client 2.3.2.Final)
JGroupsBroadcastGroupConfiguration jgroupsConfig = new JGroupsBroadcastGroupConfiguration( "jgroups.xml", "hornetq_broadcast_channel"); String name = "name"; String localBindAddress = jgroupsConfig.getLocalBindAddress(); String groupAddress = jgroupsConfig.getGroupAddress(); int groupPort = jgroupsConfig.getGroupPort(); long refreshTimeout = 1000; long discoveryInitialWaitTimeout = 1000;
But this code produces null, null and -1 for localBindAddress, groupAddress and groupPort.
I have no clue how to setup my client. Might someone help me, please?
By the way: Finally I want to setup in jgroups.xml a set of servers as seed servers. I aim to 1 live and 2 backup servers using unicast.
Regards
Stephan