Hi,
Here is a question from Epractize mock exam.
ATMEJB has a method withdrawal() with required transaction attribute and is calling AccountEJB method getAmount(). At the same time, ChequeProcessorSessionEJB is calling getAmount() method of AccountEJB without any transaction context.
The alogorithm for getAmount() is to deduct the amount from account balance, calculate interest, update history and return the requested amount to the caller.
Question : What best describes the AccountEJB component?
Answers:
a) AccountEJB should be stateless seesion EJB with RequiresNew transaction attribute for getAmount()
b) AccountEJB should be implemented as BMP with Required transaction attribute for getAmount()
c) AccountEJB should be implemented as CMP with Supports transaction attribute for getAmount()
d) AccountEJB should be implemented as CMP with RequiresNew transaction attribute for getAmount()
The correct answer mentioned is d)
But I am not convinced with RequiresNew transaction attribute for getAmount() as if getAmount() method is executed successfully but withdrawal() method fails, still the amount will be deducted from customer's account.
In my understanding Required should be the transaction attribute, but i don't see any need for BMP here.
Please comment.
TIA,
- Tinu