-->
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.  [ 1 post ] 
Author Message
 Post subject: Help Required - Synchronisation issue with hibernate and JMS
PostPosted: Wed Oct 26, 2011 6:23 am 
Newbie

Joined: Tue Jul 19, 2011 12:25 pm
Posts: 4
Hi,

I am struggling with a synchronisation problem when using hibernate and JMS under JBOSS AS 6.0.0.Final.
Forgive me if I get my terminology wrong, I am far from an expert in this!

I use a database facade class to perform all of my DB operations, which includes my entity manager persistence context. This 'dbFacade' class is injected into both my sending and listening beans.

In my sending class, I am using the injected dbFacade (and it's entity manager) to retrieve and modify the property of a component, which I then merge and flush the entity manager.

I subsequently use JMS to send a message to an MDB to perform some asynchronous operations (so I can return the UI to the user).
The JMS message includes a reference to the component id in my database (MySQL).

My MDB injects the dbFacade and the 'onMessage' method retrieves the component form the database using the component id.
The problem is that the retrieved component does not include the modifications made before the message was sent.

For example I set the component status to a value, but the component retrieved in the onMessage method has a different value (the prior value).

I am able to get around this problem by forcing the MDB to sleep a few seconds before retrieving the component, which suggests this is a timing issue, where the modifications in the sending class have not been written back to the database before they are read by the MDB.

Is there a better way to handle this scenarion? Some Ideas I had were...

1/ Do I need to make my dbFacade a singleton - is this an issue with the sending class and the MDB using different entity managers?
2/ Is there a way to force the entity manager to write the changes back to the db before sending the message (Apart from calling flush() on the entity manager which I am already doing)
3/ Should I look to use @Asynch rather than MDB's

Any other ideas???
Thanks in advance
Rich


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.