-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JMS Master/Slave stops writing to index
PostPosted: Thu Mar 07, 2013 12:52 pm 
Newbie

Joined: Thu Mar 07, 2013 12:24 pm
Posts: 1
We upgraded to 4.1.1 and want to now start using jms master/slave because of nfs issues in a clustered environment. Using tomcat 6 with activemq. Running into this issues where all of a sudden the indexes don't update on the master - no errors, nothing. I can reproduce it everytime if I run the mass indexter from a slave. Within about 10 minutes or so I can see the indexes aren't being updated. Below is config for master and slave...
//master
Code:
<entry key="hibernate.search.default.sourceBase" value="${searchMaster.baseDir}" />
          <entry key="hibernate.search.default.indexBase" value="${searchIndexes.baseDir}" />
          <entry key="hibernate.search.default.refresh" value="300" />
          <entry key="hibernate.search.default.optimizer.operation_limit.max" value="2000" /> 
          <entry key="hibernate.search.default.exclusive_index_use" value="true" />

//slave
          <entry key="hibernate.search.default.directory_provider" value="${searchDirectoryProvider}" />
          <entry key="hibernate.search.default.sourceBase" value="${searchMaster.baseDir}" />
          <entry key="hibernate.search.default.indexBase" value="${searchIndexes.baseDir}" />
          <entry key="hibernate.search.default.refresh" value="300" />
          <entry key="hibernate.search.default.optimizer.operation_limit.max" value="2000" /> 
          <entry key="hibernate.search.default.exclusive_index_use" value="true" />
         <entry key="hibernate.search.default.worker.backend" value="jms" />
         <entry key="hibernate.search.default.worker.jms.connection_factory" value="java:comp/env/jms/ConnectionFactory" />
         <entry key="hibernate.search.default.worker.jms.queue" value="java:comp/env/jms/queue/hibernatesearch" />


//master controller

Code:
public class HibernateSearchController extends AbstractJMSHibernateSearchController implements MessageListener {

   // method retrieving the appropriate session
   protected Session getSession() {
      EntityManager em = null;
      try {
         em = getEm();
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
      return (Session) em.getDelegate();
   }
   
   private EntityManager getEm() throws InterruptedException {
      EntityManager em = AbstractPersistentEntity.getEm();
      if (em == null) {
         Thread.sleep(60000);
         em = getEm();
      }
      return em;
   }

   // potentially close the session opened in #getSession(), not needed here
   protected void cleanSessionIfNeeded(Session session) {
   }

   public void register() {
      try {
         System.out.println("registering " + getClass().getName());
         Context initCtx;

         initCtx = new InitialContext();

         ConnectionFactory connectionFactory = (ConnectionFactory) initCtx.lookup("java:comp/env/jms/ConnectionFactory");
         Connection connection = connectionFactory.createConnection();
         connection.start();
         javax.jms.Session session = connection.createSession(true, 0);

         // Look up for destination and set listner
         Queue queue = (Queue) initCtx.lookup("java:comp/env/jms/queue/hibernatesearch");
         MessageConsumer consumer = session.createConsumer(queue);
         consumer.setMessageListener(this);
         
         System.out.println("done registering " + getClass().getName());

      } catch (Exception e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
   
   @Override
    public void onMessage(Message message) {
       //System.out.println("recieved message");
       super.onMessage(message);
    }
}



Are there any other debugging options other than just turning on debug for org.hibernate.search?


Top
 Profile  
 
 Post subject: Re: JMS Master/Slave stops writing to index
PostPosted: Fri Mar 08, 2013 8:09 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
These getEm() and getSession() implementations are extremely dangerous: you're forcing it to throw an InterruptedException, then fail to clean the interruption state of the running thread.

Also, why do you think you don't need to clean the Session?

I guess you're both starving threads and database connections with these errors.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.