This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

My exam cloud, mock 4, about onMessage get a runtime exception and rollback  RSS feed

 
Ranch Hand
Posts: 1733
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You are developing a message-listener method of an EJB 3.0 message driven bean. You need to make sure that the message receipt is immediately rolled back in case the message listener method is aborted with a runtime exception
Select the best design approach.
A. Use container managed transaction with transaction attribute REQUIRED.
B.Use container managed transaction with transaction attribute NOT_SUPPORTED
c. use bean managed transactions and the JMS API for message acknowledgement
d. Use bean managed transaction and write a try-catch-finally block that calls UserTransaction.rollback in case of a RuntimeException

Given answer :A

Explanation:
Based on the requirements, CMT with REQUIRED transaction attribute is the correct answer. REQUIRED transaction attribute run a method within a transaction and rollback if there is any runtime exception.



I think if the runtime exception is an application exception, using CMT with REQUIRED may not rollback the transaction if the application exception specify rollback=false.
I think D is the best approach because it explicitly specifies that the transaction needs to be rollback when the exception occurs.
 
It's just a flesh wound! Or a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!