I am reading this blog about transaction handling in container managed transactions.
The author clearly demarcates the difference between EJB transaction and database transaction. A database transaction is just one of the EJB transactions.
Consider this example:
Take a money transaction. That is not only changing some numbers around in one or more databases. There is also administration, notification, confirmation and validation going on.
Based on this example consider the following stateless bean,
@Stateless
public class MoneyTransactionBean {
public void MoneyTransfer(int amount, BankAccount from, BankAccount to){
//db transaction
/ // adminstration transaction //JMS
// confirmation //JMS
// Notification //JSP
// validation //EJB
// email //JMAIL
}
}
Scenario 1: If the Notification step fails, does the JMS transaction associated with Confirmation get rolled back? In other words, will the JMS message be dequeued i.e Notification event is cleared from JMS queue?
Scenario 2:
If all individual transactions (invoked on respective beans) are successful but Validation
fails will the JMS message from the confirmation step be rolled back and will the email be dequeued?
How does the rollback of the transaction happen in this case?