• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Should I always separate logic from MessageDrivenBean?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In compare with Stateless Session Bean (SLSB), there are many limitations on MesageDrivenBean (MDB). I met a problem now:

In the onMessage function of my MDB, I do some job about Database (with help of a SLSB DAO, TransactionType is Require), after that I send the reponse message back. But I got a problem because I try to update database and send message in the same tranaction, which should be two-phase commit. I use HSQLDB inside JBoss, it doesn't support the two-phase commit. So I have to separate the database operation and send message operation in two different transaction. The question is how?

Should I make another SLSB, only for sending message? Or I have to change the TransactionType of DAO to Require_New?
Is there any better solution?

thanks.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> I have to change the TransactionType of DAO to Require_New?

I dont see what else you can do. Be reminded that a rollback of the outer transaction will not undo the commits made by the inner one. So you may have to manually compensate for the changes by the dao if the msg sending from within the mdb failed.

cheers.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic