-->
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.  [ 8 posts ] 
Author Message
 Post subject: Setup Master/Slave configuration
PostPosted: Thu May 03, 2007 6:18 pm 
Hibernate Team
Hibernate Team

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

I am about to test a Master/Slave setup for Hibernate Search and I am a little bit confused on what is required for that.

The properties I have to set in the configuration files seems to be straight forward, the problem I have is the JMS queue. I was hoping to run my applications within Tomcat and I was under the impression that Hibernate Search will start it's own JMS queue automatically when configured for a Master /Slave setup. But reading the documentation I am not so sure anymore. Do I need a independent JMS queue? Do I have to for example use JBoss instead of Tomcat, or should I use the embedded JBoss? Or even another JMS queue implementation?

I must admit I haven't even started trying to configure it properly, so please don't shoot me in case this Hibernate Search has everything inbuild ;-)

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 8:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You need somehow to have a JMS provider. So your choices are:
- Tomcat + a JMS provider + a way to trigger some work on a message retrieval (like MDB does)
- tomcat + JBoss Embedded
- JBoss AS

I ordered the solutions from the most complex and untested to the easiest and most tested.

I just don't understand people using tomcat + all the needed services over JBoss As (where you can also define which service you want to activate.

Note I might provide a JMS-less clustering solution, but it's not very high on my todo list. A bootstraped JBoss Messaging might be interesting

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Bootstraping JMS solution
PostPosted: Fri May 04, 2007 1:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Thanks, this is the information I was looking for. I kind of suspected that this would be the answer, but it is good to see it spelled out. :)

I think a way of bootstrapping would really be nice. I guess JBoss embedded would be the way forward.

I guess I start with installing on JBoss. That seems to be the path of least resistance.

--Hardy


Top
 Profile  
 
 Post subject: ActiveMQ
PostPosted: Tue May 08, 2007 5:04 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I decided to first try ActiveMQ. Setting up a JMS queue is pretty straight forward: ActiveMQ+Tomcat.
Has anyone tries this setup before?

emmanuel wrote:
Note I might provide a JMS-less clustering solution, but it's not very high on my todo list. A bootstraped JBoss Messaging might be interesting


That's sounds very interesting. I also would like to see a bootstrapping solution. Maybe not necessarily with JBoss. Any ideas how this should work?

Cheers,
Hardy


Top
 Profile  
 
 Post subject: ActiveMQ configuration
PostPosted: Fri May 11, 2007 4:23 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I thought someone might be interested in a ActiveMQ setup. It turned out be be quite easy as well.

The following assumes you are using Tomcat and have two seperate web applications - say a master and a slave one ;-)

First step is to make sure that each of the applications has its own hibernate configuration according to the Hibernate Search documentation.

Next step is to make sure that JNDI is setup properly. Just add the following to the context.xml of your apps.

Code:
        <!-- ActiveMQ ConnectionFactory -->     
        <Resource name="jms/ConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory"
                description="JMS Connection Factory" factory="org.apache.activemq.jndi.JNDIReferenceFactory"
                brokerURL="vm://localhost"  brokerName="LocalActiveMQBroker"/>

        <!-- ActiveMQ HibernateSearch queue -->
        <Resource name="queue/hibernatesearch" auth="Container" type="org.apache.activemq.command.ActiveMQQueue"
                description="Hiebrnate search queue" factory="org.apache.activemq.jndi.JNDIReferenceFactory"
                physicalName="HibernateSearchController"/>



In case you are using maven you can add the following dependency to your pom.xml to get the ActiveMQ dependencies:

Code:
                <dependency>
                        <groupId>org.apache.activemq</groupId>
                        <artifactId>activemq-core</artifactId>
                        <version>4.1.1</version>
                </dependency>


Next step is to implement a subclass of AbstractJMSHibernateSearchController in the master application. This class has to register itself as listener to the queue. The code could look somewhat like this:

Code:
                Context initCtx = new InitialContext();

                // Look up for connection factory & create connection, session
                ConnectionFactory connectionFactory = (ConnectionFactory) initCtx.lookup("java:comp/env/jms/ConnectionFactory");       
                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/queue/hibernatesearch");
                MessageConsumer consumer = session.createConsumer(queue);
                consumer.setMessageListener(this);


Last but not least you have to make sure that this code is executed at application startup, eg by implementing a startup listener.

That's pretty much it. Not too hard I think.

I hope it helps someone.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 11:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Nice I put it on the wiki
http://www.hibernate.org/421.html

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: ActiveMQ configuration
PostPosted: Sat May 02, 2009 1:57 pm 
Newbie

Joined: Fri May 01, 2009 1:48 pm
Posts: 4
hardy.ferentschik wrote:
I thought someone might be interested in a ActiveMQ setup. It turned out be be quite easy as well.


I don't think so. It looks like that your master and slave application are both installed on the same Tomcat instance. I think that is impossible to run master/slave configuration on different Tomcat instances (servers) because Tomcat doesn't expose it's JNDI context externally so slave can't connect to it. Did you try it? That is a reason to use JBoss AS over Tomcat because JBoss AS exposes its JNDI context via jnp://server:1099.

Your example at http://www.hibernate.org/421.html is really great and promising but it's incomplete - master and slave configurations for Hibernate Search are missing and it's not clear on which node the ConnectionFactory and the queue/hibernatesearch are created.


Top
 Profile  
 
 Post subject: Re: Setup Master/Slave configuration
PostPosted: Tue May 05, 2009 6:47 am 
Newbie

Joined: Tue May 05, 2009 4:39 am
Posts: 1
Master-lave setup is not so benificial.In this slave totally depends on master.Thats the major problem.

_________________
generic viagra online,kamagra,kamagra oral jelly,silagra,meltabs


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