I configured my code as below and it works only if I wait for the refresh times. I wish my code to run and perform connections to master and slave servers from client. I can't reach to the correct data because the lucene index performs the write action to the master as the client performs an action on slave. when I reduce the refresh time, I got the error "Unable to determine current in source directory, will try again during the next synchronization". how can I make the slave and master server lucene indexes to run as they must be when I perform any action?
//Master
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/beans/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="baseSessionFactory" />
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/context/db.properties" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/db"/>
</bean>
<bean id="baseSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="packagesToScan">
<list>
<value>model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${database.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
<!-- Cluster Mode Hibernate Search -->
<prop key="hibernate.search.default.indexBase">${index.directory}</prop>
<prop key="hibernate.search.default.sourceBase">${index.master.directory}</prop>
<prop key="hibernate.search.default.refresh">120</prop>
<!-- Master Node Hibernate Search -->
<prop key="hibernate.search.default.directory_provider">filesystem-master</prop>
<!-- End Of Master Node Hibernate Search -->
</props>
</property>
</bean>
<!-- Cluster Mode Master Node JMS Configuration -->
<bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
<property name="config" value="classpath:/context/activemq.xml" />
<property name="start" value="true" />
</bean>
<bean name="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jms/ConnectionFactory" />
</bean>
<bean name="jmsHibernateSearchQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="queue/hibernatesearch" />
</bean>
<bean id="hibernateSearchController" class="util.search.HibernateMasterNodeSearchListener">
</bean>
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
depends-on="broker">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="destination" ref="jmsHibernateSearchQueue" />
<property name="messageListener" ref="hibernateSearchController" />
</bean>
<!-- End Of Cluster Mode Node JMS Configuration -->
</beans>
//Slave
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/beans/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="baseSessionFactory" />
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/context/db.properties" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/db"/>
</bean>
<bean id="baseSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="packagesToScan">
<list>
<value>model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${database.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.search.default.indexBase">${index.directory}</prop>
<prop key="hibernate.search.default.sourceBase">${index.master.directory}</prop>
<prop key="hibernate.search.default.refresh">40</prop>
<prop key="hibernate.search.default.buffer_size_on_copy">128</prop>
<prop key="hibernate.search.default.directory_provider">filesystem-slave</prop>
<prop key="hibernate.search.worker.backend">jms</prop>
<prop key="hibernate.search.worker.jms.connection_factory">jms/ConnectionFactory</prop>
<prop key="hibernate.search.worker.jms.queue">queue/hibernatesearch</prop>
<prop key="hibernate.search.worker.execution">sync</prop>
</props>
</property>
</bean>
</beans>