• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic