-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate search and JMS missunderstanding things
PostPosted: Tue Jul 08, 2008 6:06 am 
Newbie

Joined: Tue May 20, 2008 11:14 am
Posts: 7
Hello,

I'm trying to use hibernate search with jms but it still doesn't work.
I've created a standalone java application with hibernate search.
My onMessage method inside my mdb class is not fire why?
I'm using annotation and cfg file to setup hibernate.
I have 2 applications one who send message on a jms queue called queue/FullDoc inside a JBoss 4_0_5 server and an other one (standalone) who is using hibernate search.
In the second one I have this class:

public class MDBSearchController extends AbstractJMSHibernateSearchController

implements MessageListener {


@PersistenceContext

EntityManager em;


protected Session getSession() {

return (Session) em.getDelegate();

}


protected void cleanSessionIfNeeded(org.hibernate.Session arg0) {

}


public MDBSearchController() {

// TODO Auto-generated constructor stub

}


@Override

public void onMessage(Message arg0) {

// super.onMessage(arg0);

TextMessage text = (TextMessage) arg0;

try {

index(text.getText());

} catch (JMSException e) {

e.printStackTrace();

}

}

....

}


And I have this config file:

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">

com.mysql.jdbc.Driver

</property>

<property name="hibernate.connection.username">test</property>

<property name="hibernate.connection.password">test</property>

<property name="hibernate.connection.url">

jdbc:mysql://localhost:3306/hibernate_test

</property>

<property name="hibernate.default_schema">

hibernate_test

</property>

<property name="hibernate.dialect">

org.hibernate.dialect.MySQLDialect

</property>

<property name="show_sql">true</property>

<!-- <property name="hibernate.search.default.directory_provider">

org.hibernate.search.store.FSDirectoryProvider

</property> -->

<property name="hibernate.search.default.directory_provider">

org.hibernate.search.store.FSMasterDirectoryProvider

</property>

<property name="hibernate.search.worker.backend">

jms

</property>

<property name="hibernate.search.worker.jndi.java.naming.factory.initial">

org.jnp.interfaces.NamingContextFactory

</property>

<property name="hibernate.search.worker.jndi.java.naming.provider.url">

tradluxwsi03293:1099

</property>

<property name="hibernate.search.worker.jndi.java.naming.factory.url.pkgs">

org.jboss.naming:org.jnp.interfaces

</property>

<property name="hibernate.search.worker.jms.connection_factory">

ConnectionFactory

</property>

<property name="hibernate.search.worker.jms.queue">

queue/FullDoc

</property>

<property name="hibernate.search.default.sourceBase">

R:\temp\release

</property>

<property name="hibernate.search.default.indexBase">

R:\temp

</property>



<property name="hibernate.search.default.refresh">

1800

</property>

<mapping class="europarl.itstrad.hiberluc.model.Document" />

<mapping class="europarl.itstrad.hiberluc.model.FDR" />

<event type="post-update">

<listener

class="org.hibernate.search.event.FullTextIndexEventListener" />

</event>

<event type="post-insert">

<listener

class="org.hibernate.search.event.FullTextIndexEventListener" />

</event>

<event type="post-delete">

<listener

class="org.hibernate.search.event.FullTextIndexEventListener" />

</event>

</session-factory>

In the console I rerived this:

08-Jul-2008 10:18:55 org.hibernate.impl.SessionFactoryObjectFactory addInstance

INFO: Not binding factory to JNDI, no JNDI name configured



My question is why in my listener class I retrived any message???

Thanks in advence.


Top
 Profile  
 
 Post subject: Re: Hibernate search and JMS missunderstanding things
PostPosted: Tue Jul 08, 2008 11:07 am 
Hibernate Team
Hibernate Team

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

Quote:
I have 2 applications one who send message on a jms queue called queue/FullDoc inside a JBoss 4_0_5 server and an other one (standalone) who is using hibernate search.

Are not both applications using Hibernate Search? You need at least one master, which is responsible for indexing and sharing out the index to the slave instances. The master application is the one which needs a message listener, speak MDBSearchController. This controller will be called for each index request from one of the slaves.

Then there are of course the salves. There has to be at least one.

Last but not least you need a message broker, speak JMS queue. In your case you are using the messaging services from JBoss.

Quote:
In the second one I have this class:

public class MDBSearchController extends AbstractJMSHibernateSearchController

implements MessageListener {
...

And how do you make this class a consumer of the JMS queue? You will have somehow register the listener. In the example in the online doc (http://www.hibernate.org/hib_docs/search/reference/en/html_single/#jms-backend)
Code:
@MessageDriven(activationConfig = {
      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
      @ActivationConfigProperty(propertyName="destination", propertyValue="queue/hiebrnatesearch"),
      @ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="1")
   } )

is used. This is of course only working within a J2EE container. If you run standalone you will have to register your listener. Have a look at this http://hibernate.org/421.html.

Regarding your config file it seems you are mixing properties from master and slave configurations. Really you should have two hibernate configuration files. One for the master and one for the slave.

I hope this helps.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 11:19 am 
Newbie

Joined: Tue May 20, 2008 11:14 am
Posts: 7
if I understand correctly I have to create a MDB who extends AbstractJMSHibernateSearchController.
In this case I have to forgot all the settings about JMS in my cfg file and the annotations @MessageDriven... in my mdb class.
Am I in the truth, in the right way?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 08, 2008 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Correct. The JMS settings are for the slave configuration and should be in the configuration of the slave.

For the master you need @MessageDriven. However, this only works in a J2EE container. If you have a standalone app you might have to write the registration code yourself.

The code looks then similar to 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);
.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 3:57 am 
Newbie

Joined: Tue May 20, 2008 11:14 am
Posts: 7
Thanks a lot so I prefere tu use the master config and create my own message driven bean.
Thanks a lot for your insights.


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