Failover not working
joydeep.sarkar Aug 16, 2010 3:25 PMHi,
I have configured Live-backup pair. But the client failover is not taking place. When the Live server(which client is looking up) is down, the client does not connect the backup server and throws exception instead.
Observations:
1. The JMX console of backup server does not show all the attributes in org.hornetq link except one.
2. When the .ear is deployed in the backup server, shows an error as "/connection factory not bound".
3. When the ConnectionFactory is obtained in the client code, the value shows there is only 1 connector available. i.e. netty factory. It shows "b" of the pair as null.
I am not quite sure if these are desired characteristics.
Also, I have made the configuration such that normal shut down also leads to failover, but of no avail.
Queries:
1) What exactly triggers the failover?
2) Is it required to have the .ear deployed in the backup server? If yes, then how would the deployment be successful if the resources are not available?( As they are not showing up in the JMX console. May be because the server is not yet activated?)
I have attached the configuration files herewith. Following is the client code,
import org.hornetq.api.jms.HornetQJMSClient; import javax.jms.*; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Properties; public class FailoverTest { public static void main(String[] args) { String queueName = null; Context jndiContext = null; ConnectionFactory connectionFactory = null; Connection connection = null; Session session = null; Queue queue = null; MessageProducer producer = null; TextMessage message = null; final int NUM_MSGS = 4; queueName = "queue/oracleXMLQueue"; try { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming :-o rg.jnp.interfaces"); props.put(Context.PROVIDER_URL, "jnp://lonmmsweb07:1199"); jndiContext = new InitialContext(props); } catch (NamingException e) { System.out.println("Could not create JNDI API " + "context: " + e.toString()); e.printStackTrace(); System.exit(1); } try { connectionFactory = (QueueConnectionFactory)jndiContext.lookup("/ConnectionFactory"); System.out.println(connectionFactory); queue = (Queue) jndiContext.lookup(queueName); connection = connectionFactory.createConnection(); session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(queue); message = session.createTextMessage(); for (int i = 0; i < NUM_MSGS; i++) { message.setText("This is message " + (i + 1)); producer.send(message); Thread.sleep(2000); } }catch (NamingException ne) { ne.printStackTrace(); } catch (JMSException e) { e.printStackTrace(); } catch(InterruptedException ie){ }finally { if (connection != null) { try { connection.close(); } catch (JMSException jmse) { jmse.printStackTrace(); } } } } }
could anyone please tell me what is the problem here?
TIA,
Joydeep
-
Live.rar.zip 3.8 KB
-
Backup.rar.zip 3.7 KB