Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Mangement with Spring JTA

 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic