Hi Balaji,
In order to achieve your requirements I'd do the following:
1. Expose
updateUSer() and
auditUser() methods in the component interface.
This is because transaction attributes can be only specified on business methods declared in the component interface (this is true for SB; for entity beans can also specify on home methods defined by bean provider plus
remove methods from EJBObject and EJBHome interfaces; for MDB - only can define trans attribute on
onMessage( Message )) method)
As you want to expose one method (
process()) in the comp interface you could define
updateUser() and
auditUser() methods in a different bean that has only local interface (only local clients can access it).
2. Make
updateUSer() run in its own transaction - in ejb-jar.xml <container-transaction> section associate this method with RequiresNew transaction attribute. This will allow the results of this methods to be commited/rollbacked as soon as the method is completed - does not depend on the outcome of the transaction in which
process() and
auditUser() run.
3. Make
auditUser() run in the caller's transaction (i.e. a transaction associated with the
process()) method) - use Required transaction attribute. This will ensure that the results of
auditUser() are only committed if
process()) method completes successfully.
If you want
auditUser() to be also independent from the caller (i.e.
process()) method) then use RequiresNew (similar to
updateUSer()).
Hope it helps
