-->
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.  [ 3 posts ] 
Author Message
 Post subject: search master onMessage infinite loop
PostPosted: Tue Oct 05, 2010 3:16 am 
Beginner
Beginner

Joined: Thu Nov 20, 2003 10:16 pm
Posts: 28
Location: Los Angeles, CA
In attempting to set up master-slave indexing using JMS/ActiveMQ, I am running into a weird problem on the master side when receiving the JMS message. The situation is the slave posts a delete-lucene-work and add-lucene-work message on the queue. The master then goes into an apparent infinite loop, as in:

Code:

received message
WARN [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (BrokerRegistry.java:52) lookup -  Broker localhost not started so using jms-broker instead
INFO [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (TransportConnector.java:250) start -  Connector vm://localhost Started
INFO [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (TransportConnector.java:285) stop -  Connector vm://localhost Stopped
received message
WARN [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (BrokerRegistry.java:52) lookup -  Broker localhost not started so using jms-broker instead
INFO [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (TransportConnector.java:250) start -  Connector vm://localhost Started
INFO [org.springframework.jms.listener.DefaultMessageListenerContainer#0-7] (TransportConnector.java:285) stop -  Connector vm://localhost Stopped
received message
etc...


I'm instatiating ActiveMQ as an embedded broker in the master, with two transports: vm and tcp.

My configuration:

Code:
  <!-- ActiveMQ Configuration -->
  <amq:broker
    id="jmsBroker"
    brokerName="jms-broker"
    persistent="false"
    start="true"
  >
    <amq:destinations>
      <amq:queue id="hibernateSearchQueue" physicalName="queue/HibernateSearch" />
    </amq:destinations>
   
    <!--
    <amq:persistenceAdapter>
      <amq:amqPersistenceAdapter directory="${jms.provider.workDir}/data" maxFileLength="32mb"/>
    </amq:persistenceAdapter>
    -->
   
    <amq:transportConnectors>
      <amq:transportConnector uri="${jms.provider.url}"/>
      <amq:transportConnector uri="vm://jms-broker"/>
    </amq:transportConnectors>
  </amq:broker>

  <amq:connectionFactory id="jmsConnectionFactory" brokerURL="vm://jms-broker"/>

  <!-- Hibernate Configuration -->
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" depends-on="jmsBroker" lazy-init="true">
    <property name="packagesToScan" value="${service.model.packages}"/>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
        <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
        <prop key="hibernate.use_outer_join">${hibernate.use_outer_join}</prop>
        <prop key="hibernate.byte_code.use_reflection_optimizer">${hibernate.byte_code.use_reflection_optimizer}</prop>
       
        <!-- Search Configuration -->
        <prop key="hibernate.search.default.optimizer.operation_limit.max">${hibernate.search.default.optimizer.operation_limit.max}</prop>
        <prop key="hibernate.search.default.optimizer.transaction_limit.max">${hibernate.search.default.optimizer.transaction_limit.max}</prop>
       
        <prop key="hibernate.search.default.indexBase">${hibernate.search.default.indexBase}</prop>
        <prop key="hibernate.search.default.refresh">${hibernate.search.default.refresh}</prop>
        <prop key="hibernate.search.default.sourceBase">${hibernate.search.default.sourceBase}</prop>

        <prop key="hibernate.search.worker.backend">jms</prop>
        <prop key="hibernate.search.worker.jms.connection_factory">ConnectionFactory</prop>
        <prop key="hibernate.search.worker.jms.queue">HibernateSearchQueue</prop>
               
        <!-- Search Master Configuration -->
        <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSMasterDirectoryProvider</prop>       
        <prop key="hibernate.search.default.exclusive_index_use">true</prop>
      </props>
    </property>
    <property name="dataSource">
      <ref bean="dataSource" />
    </property>
    <property name="lobHandler">
      <bean class="org.springframework.jdbc.support.lob.DefaultLobHandler" />
    </property>
  </bean>
 
  <!-- JMS Index-Update Messages -->
  <bean id="searchQueueListener" class="org.csmc.indexer.persistence.impl.hibernate.SearchQueueListener">
    <constructor-arg><ref bean="sessionFactory" /></constructor-arg>
  </bean>

  <jms:listener-container connection-factory="jmsConnectionFactory" transaction-manager="transactionManager">
    <jms:listener destination="queue/HibernateSearch" ref="searchQueueListener" />
  </jms:listener-container>

  <!-- Transactions -->
  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
  </bean>


My search listener class:

Code:
public class SearchQueueListener extends AbstractJMSHibernateSearchController
{
  //~ Members ----------------------------------------------------------------------------------------------------------

  private SessionFactory sessionFactory;

  //~ Constructors -----------------------------------------------------------------------------------------------------

  public SearchQueueListener(SessionFactory sessionFactory)
  {
    this.sessionFactory = sessionFactory;
  }

  //~ Methods ----------------------------------------------------------------------------------------------------------

  @Override
  public void onMessage(Message message)
  {
    System.out.println("received message");
    super.onMessage(message);
  }

  @Override
  protected void cleanSessionIfNeeded(Session session)
  {
    SessionFactoryUtils.releaseSession(session, sessionFactory);
  }

  @Override
  protected Session getSession()
  {
    return SessionFactoryUtils.getSession(sessionFactory, true);
  }


My /jndi.properties:

Code:
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory

java.naming.provider.url = vm://localhost

connectionFactoryNames = ConnectionFactory

queue.HibernateSearchQueue = queue/HibernateSearch


What could be going on?

Michael


Top
 Profile  
 
 Post subject: Re: search master onMessage infinite loop
PostPosted: Tue Oct 05, 2010 6:24 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 10:16 pm
Posts: 28
Location: Los Angeles, CA
For anyone running into the same issue, the problem was I had inadvertently configured the master with the jms mode. This caused it resubmit the received message back onto the queue, causing a loop. Solution was to remove the lines configuring the workers to use the jms backend from the Hibernate xml configuration.


Top
 Profile  
 
 Post subject: Re: search master onMessage infinite loop
PostPosted: Wed Oct 06, 2010 6:27 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
For anyone running into the same issue, the problem was I had inadvertently configured the master with the jms mode.

Right, thanks for coming back and explaining it.

_________________
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.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.