-
1. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
ataylor Jul 15, 2013 8:46 AM (in response to poonamkamboj)how is your client configured to reconnect
-
2. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
poonamkamboj Jul 15, 2013 8:51 AM (in response to ataylor)client is not reconnecting , only JNDI is configured for HA. Client tries connects to only live server URL every time (since this is the providerURL loaded intiially only once and used for initial context lookup)
-
3. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
ataylor Jul 15, 2013 8:53 AM (in response to poonamkamboj)client is not reconnecting , only JNDI is configured for HA. Client tries connects to only live server URL every time (since this is the providerURL loaded intiially only once and used for initial context lookup)
I'm a bit confused as to what your issue is then, you said the client was not reconnecting?
-
4. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
poonamkamboj Jul 15, 2013 8:57 AM (in response to ataylor)client connects fine to live server, but once live server is down, client program (in web application) doesn't automatically switch to Backup server, (as i read in one of the hornetq forums if ConnectionFactory is configured for HA, clients will be able to automatically connect to backup server once live server is down)
-
5. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
ataylor Jul 15, 2013 9:00 AM (in response to poonamkamboj)client connects fine to live server, but once live server is down, client program (in web application) doesn't automatically switch to Backup server, (as i read in one of the hornetq forums if ConnectionFactory is configured for HA, clients will be able to automatically connect to backup server once live server is down)
Thats what i was asking, how is your client configured, i.e. how is it connecting, code etc?
-
6. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
poonamkamboj Jul 15, 2013 9:14 AM (in response to poonamkamboj)JNDI entires are loaded once as follows in static block
=========================================================================================================================================================
static{
InputStream jndiStream =
MessageQueue.class.getClassLoader().getResourceAsStream("jndi.properties");
try {
jndiProperties.load(jndiStream);
} catch (IOException e1) {
e1.printStackTrace();
}
Properties initialContextProperties = new Properties();
if (!isNullOrEmpty(jndiProperties.getProperty("initialContextFactory"))){
initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY,
jndiProperties.getProperty("initialContextFactory"));
}
if (!isNullOrEmpty(jndiProperties.getProperty("urlPkgPrefixes"))){
initialContextProperties.put(Context.URL_PKG_PREFIXES,
jndiProperties.getProperty("urlPkgPrefixes"));
}
if (!isNullOrEmpty(jndiProperties.getProperty("brokerURL"))){
initialContextProperties.put(Context.PROVIDER_URL,
jndiProperties.getProperty("brokerURL"));
}
initialContextProperties.put(Context.SECURITY_PRINCIPAL,
jndiProperties.getProperty("userName"));
initialContextProperties.put(Context.SECURITY_CREDENTIALS,
jndiProperties.getProperty("password"));
try {
initialContext = new InitialContext(initialContextProperties);
System.out.println(" Initial Context Factory got Setup ");
_queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(jndiProperties.getProperty("connectionFactory"));
}
catch (NamingException e) {
e.printStackTrace();
}catch (javax.jms.JMSException jmse)
{
jmse.printStackTrace();
}
}
=========================================================================================================================================================
connect method (called everytime for connection)
=========================================================================================================================================================
_connect = _queueConnectionFactory.createQueueConnection(jndiProperties.getProperty("userName"),jndiProperties.getProperty("password"));
if(_connect !=null)
{
_connect.setExceptionListener(_exceptionListener);
_session = _connect.createQueueSession(true, javax.jms.Session.CLIENT_ACKNOWLEDGE);
System.out.println("===QueueSession got created===");
}
else
{
throw new NamingException();
}
=========================================================================================================================================================
sends the message
=========================================================================================================================================================
receives reply
=========================================================================================================================================================
close the session and connection
So above steps happens for each message except JNDI lookup entries.
-
7. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
ataylor Jul 15, 2013 9:24 AM (in response to poonamkamboj)well your error looks like a jndi error not a HornetQ, i.e. "Failed to connect to any of the live server "remote://live-server-ip:live-server-port".
Also, you are creating a new connction every time you send a message which is an anti pattern, connections should be long lived. This also means that it will use the details of the connection facory you looked up whjen it tries to connect.
-
8. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA problem
poonamkamboj Jul 17, 2013 4:06 AM (in response to poonamkamboj)Thanks Andy for the clarification.
We started with putting 2 provider URLs (live server, backup server), then producers/consumers were able to switch to backup serve when live server is down.