-->
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.  [ 9 posts ] 
Author Message
 Post subject: Hibernate Search JMS integration with Spring?
PostPosted: Tue May 20, 2008 10:27 am 
Newbie

Joined: Tue May 20, 2008 9:33 am
Posts: 6
Hibernate version: 3.2.6 GA
Hibernate Search version: 3.0.1 GA
Spring version: 3.5.2

Hi,

I've successfully integrated Spring with Hibernate Search.

I would like to setup the JMS slave/master mode but I'm using tomcat so I can't use the AbstractJMSHibernateSearchController...

From the documentation:
Quote:
This example inherit the abstract JMS controller class available and implements a JavaEE 5 MDB. This implementation is given as an example and, while most likely more complex, can be adjusted to make use of non Java EE Message Driven Beans.


Can somebody provides a working example on how to index from the master node?


Regards,
Cedric.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 11:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Cedric,

I've successfully used Tomcat together with ActiveMQ. Have a look at this wiki page: http://hibernate.org/421.html.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 11:08 am 
Newbie

Joined: Tue May 20, 2008 9:33 am
Posts: 6
thanks Hardy

I think I'm going to use this --> http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-asynchronousMessageReception

And inject the hibernate session factory to the subclass of AbstractJMSHibernateSearchController.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 11:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

wouldn't you still need a JMS Provider - be it JBoss MQ, Active MQ or OpenJMS? As far as I understand Spring just offers convenience methods/templates around sending and receiving messages. You still need a message broker though. I thought that's what you were asking for.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 11:57 am 
Newbie

Joined: Tue May 20, 2008 9:33 am
Posts: 6
when I posted my first post, I didn't realized that Spring can do MDB POJO...
I'm fine with the JMS configuration in Spring, we are using SwiftMQ for the broker (too much issue with the latest ActiveMQ)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Cool. Maybe you can post your setup/configuration once you have it working or you could amend the wiki page. It is always good to have some concrete examples.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 6:53 am 
Newbie

Joined: Tue May 20, 2008 9:33 am
Posts: 6
I've setup my application to use a slave FS directory and when I'm starting the webapp I'm getting this:

Code:
Caused by: org.hibernate.HibernateException: Unable to initialize: xxxxx
   at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:147)
   at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProviders(DirectoryProviderFactory.java:75)
   at org.hibernate.search.impl.SearchFactoryImpl.initDocumentBuilders(SearchFactoryImpl.java:260)
   at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:94)
   at org.hibernate.search.impl.SearchFactoryImpl.getSearchFactory(SearchFactoryImpl.java:172)
   at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:42)
   at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:417)
   at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1310)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:816)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:734)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)
   ... 103 more
Caused by: java.lang.IllegalStateException: No current marker in source directory
   at org.hibernate.search.store.FSSlaveDirectoryProvider.initialize(FSSlaveDirectoryProvider.java:56)
   at org.hibernate.search.store.DirectoryProviderFactory.createDirectoryProvider(DirectoryProviderFactory.java:144)



For the master side, I've done a simple web app which include the Hibernate MDB and the slave hibernate entities.
The master indexes are not created on startup.

-- slave hibernate config with spring:
Code:
<entry key="hibernate.search.default.indexBase" value="/var/lucene/indexes_slave_local" />
<entry key="hibernate.search.default.sourceBase" value="/var/lucene/indexes_master" />
<entry key="hibernate.search.default.refresh" value="300" />
<entry key="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSSlaveDirectoryProvider" />
<entry key="hibernate.search.worker.backend" value="jms" />
<entry key="hibernate.search.worker.jms.connection_factory" value="jms.sms.connectionFactory" />
<entry key="hibernate.search.worker.jms.queue" value="jms.sms.indexingQ" />

-- master hibernate config with spring:
Code:
<entry key="hibernate.search.worker.execution" value="async" />
<entry key="hibernate.search.worker.thread_pool.size" value="5" />
<entry key="hibernate.search.worker.buffer_queue.max" value="50" />
<entry key="hibernate.search.default.indexBase" value="/var/lucene/indexes_master_local" />
<entry key="hibernate.search.default.sourceBase" value="/var/lucene/indexes_master" />
<entry key="hibernate.search.default.refresh" value="300" />
<entry key="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSMasterDirectoryProvider" />



Another thing in term of architecture, I'm not sure the shared directory for the index replication is good thing. The JMS provides a decouple system for indexing which what we are looking for. But the shared directory provides a single point of failure and another connection glue via NFS/SMB/RCP/whatever!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 12:20 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

In which order to the applications start? The master has to be started first since it is the one responsible for creating the indexes. They should be created at startup though. Try starting only the master. The index directories should get created. If not check your setup. Also check file permissions and make sure '/var/lucene/indexes_master' exists. The index will be created relative to this directory.

cedricbompart wrote:
I've setup my application to use a slave FS
For the master side, I've done a simple web app which include the Hibernate MDB and the slave hibernate entities.


Can you explain in more details what you mean with this? How is Hibernate configured/boot strapped?

cedricbompart wrote:
Another thing in term of architecture, I'm not sure the shared directory for the index replication is good thing. The JMS provides a decouple system for indexing which what we are looking for. But the shared directory provides a single point of failure and another connection glue via NFS/SMB/RCP/whatever!


What do you have in mind? Somehow the indexes have to be shared. Once the system is up and running a failure of, for example, NFS is in many cases acceptable (master/slave configuration is not intended for real time updates). The slaves are still functional. The index will get out of date if it misses one or more refreshes, but once NFS is back synchronization will occur again. One could monitor the NFS process to make sure that a dowtime does not get unnoticed. I believe one can even setup a redundant NFS. The same applies for Samba mounts. Of course there is always also the option of implementing a own set of directory providers using a better protocol.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 22, 2008 6:13 am 
Newbie

Joined: Tue May 20, 2008 9:33 am
Posts: 6
Previously I've been able to index my Hibernate entities using the local provider: org.hibernate.search.store.FSDirectoryProvider

I'm not using Hibernate annotations for the entities, therefore I've have to define the different event listeners in the Spring org.springframework.orm.hibernate3.LocalSessionFactoryBean:
- org.hibernate.search.event.FullTextIndexCollectionEventListener
- org.hibernate.search.event.FullTextIndexEventListener

The above setup was working as advertised...

FIXED: after playing around with the config, I need to specific the event listeners on the master side as well which is not really logical... ...otherwise Hibernate Search is not initialized!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.