GeeCON Prague 2014*
The moose likes Spring and the fly likes Transaction Mangement with Spring JTA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Transaction Mangement with Spring JTA" Watch "Transaction Mangement with Spring JTA" New topic
Author

Transaction Mangement with Spring JTA

rudresh kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 83
Hi All,

I am trying to persist the data and post a message to MDB (let us say 'responseMDB')

The transaction is started from MDB (Let us say 'request MDB'), within the On message i do persist as well as posting the message.

It works fine but in case of any exceptions the persistance/posting message are not rolled back.

I believe my transaction configuration is not correct.

Following are the details
MDB :- Container managed transaction

Spring Configuration :-



Can i know what is it i am doing wrong
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Is there a reason why you are using the HibernateTemplate. If you are using Hibernate pre 3.1 version, then the template is helpful to hide boilerplate code. If you are using 3.1 or higher it gives you no benefits at all and writing straight Hibernate/JPA code is actually better and more portable than the template.

When it comes to messaging and transactions, there is only so far the transaction can be wrapped around. So it sound like the message is already sent to a queue before the transaction has rolled back, so therefore no longer available to revert.

But you haven't posted your MDB stuff and where your transaction boundary is or its settings to help more.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
rudresh kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 83
Hi Marks,

Firstly Thanks for your reply

Can i have the example/guide for the below
"If you are using Hibernate pre 3.1 version, then the template is helpful to hide boilerplate code. If you are using 3.1 or higher it gives you no benefits at all and writing straight Hibernate/JPA code is actually better and more portable than the template."

Following are my MDB settings


EJB Code


Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I don't see or understand how an EJB MDB is connected to your Spring configuration. They seem separate and therefore I see the MDB in a transaction from the JTA and App Server but not in the Spring transaction. I am missing something, or that is your problem is that they aren't connected. Also you are swallowing any exception and therefore the transaction won't rollback in the MDB.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transaction Mangement with Spring JTA