Silent HornetQ Failover with 1 Live and 2 Backup
realkobe Jun 9, 2015 6:15 AMHi there,
I want to start 1 live and 2 backup HornetQ server with a silent failover for the client. Unfortunately I don't get a connection to the backup server that went live. Probably I did a misconfiguration but I don't know what.
I adapted the configuration from config/stand-alone/clustered example in HornetQ. See attachment
1. my live server is instance0
2. my backup server is instance1 (and later instance2, too)
When started the ports look like
> netstat -tulpen 2> /dev/null | grep java tcp6 0 0 :::62500 :::* LISTEN 1000 988888 12518/java tcp6 0 0 :::62501 :::* LISTEN 1000 988871 12518/java tcp6 0 0 :::62502 :::* LISTEN 1000 992055 12518/java tcp6 0 0 :::62503 :::* LISTEN 1000 988038 12518/java tcp6 0 0 :::40647 :::* LISTEN 1000 988716 12518/java tcp6 0 0 :::62512 :::* LISTEN 1000 988159 12549/java tcp6 0 0 :::62513 :::* LISTEN 1000 990819 12549/java tcp6 0 0 :::44691 :::* LISTEN 1000 992078 12549/java tcp6 0 0 127.0.0.1:39837 :::* LISTEN 1000 492818 2385/java udp6 0 0 :::35858 :::* 1000 988889 12518/java udp6 0 0 231.7.7.7:9876 :::* 1000 991105 12549/java udp6 0 0 231.7.7.7:9876 :::* 1000 990927 12549/java udp6 0 0 231.7.7.7:9876 :::* 1000 990890 12518/java
My Java Client (see QueueExampleForDiscovery.java in attachment) creates a connection via
private HornetQConnectionFactory createStaticFactory() { TransportConfiguration[] transportConfiguration = createTransportConfiguration(); HornetQConnectionFactory factory = HornetQJMSClient.createConnectionFactoryWithHA( JMSFactoryType.CF, transportConfiguration); setupFactory(factory); return factory; } private void setupFactory(HornetQConnectionFactory factory) { // http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/ha.html#ha.automatic.failover factory.setClientFailureCheckPeriod(Duration.ofSeconds(1).toMillis()); // 39.2.1.1 on // http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/ha.html#ha.automatic.failover factory.setInitialConnectAttempts(5); // 34.1 factory.setConfirmationWindowSize(1000000); // 34.1 factory.setReconnectAttempts(20); factory.setRetryIntervalMultiplier(1.5); factory.setMaxRetryInterval(8000); } private TransportConfiguration[] createTransportConfiguration() { return new TransportConfiguration[] { createTransportConfiguration("localhost", 62500), createTransportConfiguration("localhost", 62510), // createTransportConfiguration("localhost", 62520) }; } private TransportConfiguration createTransportConfiguration(String host, int port) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put(TransportConstants.HOST_PROP_NAME, host); map.put(TransportConstants.PORT_PROP_NAME, String.valueOf(port)); TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class .getName(), map); return tc; } connection = createStaticFactory().createConnection(); connection.start();
and in the main
connection = createStaticFactory().createConnection(); connection.start();
My Problems are
- At startup it wants to connect to the backup server (localhost:62510). As it is not live (port 62510 is not open yet) it retries until initialConnectoAttempts is reached. Is there a opportunity to say "it's ok when you find any server, you don't need to find each of them"?
- After the backup went live (port 62510 is open) I don't get connection to the backup. It throws an exception Connection failure has been detected: The connection was disconnected because of server shutdown
- When the live server chrashes and the backup becomes live, the backup server says
11:07:11,582 WARN [org.hornetq.core.client] HQ212034: There are more than one servers on the network broadcasting the same node id. You will see this message exactly once (per node) if a node is restarted, in which case it can be safely ignored. But if it is logged continuously it means you really do have more than one node on the same network active concurrently with the same node id. This could occur if you have a backup node active at the same time as its live node. nodeID=1135b5d3-0e85-11e5-94de-bbf7381e5600
Can someone please tell me how to configure a failover? (without JNDI - all examples are with JNDI)
Regards
Stephan
----
How to use my scripts:
- sh install.sh downloads a HornetQ and links it as current
- sh install-instance.sh 0 copies configurations from config/stand-alone/clustered , includes queues.xml and sets the ports 62500 to 62504 (netty and jnp)
- sh start-instance.sh 0 starts the live server
- for backup server the same just replace 0 by another number and "-backup true"
- I installed with sh install-instance.sh 0 && sh install-instance.sh 1 -backup true && sh install-instance.sh 2 -backup true
-
hornetq.zip 20.4 KB