• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
Ranch Hand
Posts: 1748
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.
 
Just the other day, I was thinking ... about this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!