users@glassfish.java.net

entityManager.persist and JMS messaging issue

From: <glassfish_at_javadesktop.org>
Date: Thu, 05 Feb 2009 14:21:23 PST

Hi everyone:

I am seeing a problem that I could not figure out a solution. Can anyone shed me some lights on this?

I have a EJB method which basically does 2 things: 1). persists a record into a database table using EntityManager 2). sends out a message to a JMS topic. So it is sth like:

myMethod() {
entityManager.persist(myObj);
notifier.notify(...);
}

The client will then listen to the JMS topic and read the new record from database. Usually this works pretty well, but sometimes, the client cannot find the new record from database at all and a few seconds later it can. It is as if there is a delay between the JMS messaging and database persistence - somehow the client receives the message first and at this time the record is not really saved into database yet!

Can anyone explain to me what is going on here? What kind of solutions might help to resolve this?

BTW, I am using the Hibernate EntityManager and my app server is Glassfish.

Thanks a lot for your help

jmao
[Message sent by forum member 'jmao' (jmao)]

http://forums.java.net/jive/thread.jspa?messageID=330425