standalone non-clustered failover
anoopg2811 Dec 13, 2012 1:37 AMHi,
I am new to hornetq and we have a need to setup an active-backup HA setup which is standalone and non clustered (they share the same journal directories). Also we use spring on the client side with the jndi template. The hornetq-configuration.xml looks like this (truncating for brevity), Please note, there is no broadcast ip since this is non clustered :
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
<paging-directory>${data.dir:/Users/anoop/Projects/hornetq/hornetq-san/data}/paging</paging-directory>
<bindings-directory>${data.dir:/Users/anoop/Projects/hornetq/hornetq-san/data}/bindings</bindings-directory>
<journal-directory>${data.dir:/Users/anoop/Projects/hornetq/hornetq-san/data}/journal</journal-directory>
<journal-min-files>10</journal-min-files>
<large-messages-directory>${data.dir:/Users/anoop/Projects/hornetq/hornetq-san/data}/large-messages</large-messages-directory>
<backup>false</backup>
<shared-store>true</shared-store>
<failover-on-shutdown>true</failover-on-shutdown>
<allow-failback>true</allow-failback>
<!-- Enable Security - you can also disable it for testing reasons -->
<security-enabled>true</security-enabled>
<connectors>
<connector name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</connector>
<connector name="netty-throughput">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:localhost}"/>
<param key="port" value="${hornetq.remoting.netty.batch.port:5455}"/>
<param key="batch-delay" value="50"/>
</connector>
</connectors>
The jndi props look like the following:
jndi.provider.url=jnp://localhost:1099,localhost:2099
jndi.factory.init=org.jnp.interfaces.NamingContextFactory
jndi.factory.pkgs=org.jboss.naming:org.jnp.interfaces
The spring configuration is :
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.provider.url">${jndi.provider.url}</prop>
<prop key="java.naming.factory.initial">${jndi.factory.init}</prop>
<prop key="java.naming.factory.url.pkgs">${jndi.factory.pkgs}</prop>
</props>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref ="jndiTemplate"/>
<property name="jndiName" value="ConnectionFactory"/>
</bean>
The exception trace is as follows when I kill the live server. I was expecting the backup server would start taking up the connections.
Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at net.sf.ehcache.distribution.jms.JMSUtil.lookup(JMSUtil.java:181)
at net.sf.ehcache.distribution.jms.JMSCacheManagerPeerProviderFactory.createCachePeerProvider(JMSCacheManagerPeerProviderFactory.java:109)
... 95 more