Transaction Management Issues While Dealing with Underlying Database and Proposed Resolutions in CE 7.1.1 SP03
SAP NetWeaver provides a framework called the Composite Application Framework which supports the development of composite applications on SAP NetWeaver platform based on SAP assets like SAP ERP, SAP CRM, etc as well as non-SAP assets available in the landscape. This framework also comes up with a persistence layer for storing business data. Transaction management while dealing with business data is a major challenge. This write-up is about pinpointing some pain points in that area.
Say, for example I have two CAF Application Services CAF-App Service1 and CAF-App Service2. CAF-App Service1 is calling several other CAF-App services having functionalities like Functionality1, Functionality2… for serving specific business purposes. Now say, CAF-App Service1 is calling CAF-App Service2 for the business functionality Functionality5 where business data needs to be updated in CAF-BO. But Functionality7 needs the updated business data that was updated by Functionality5 which is now not available because of improper transaction management.
- Terminate T1 transaction so that CAF BO “UPDATE” operation is completed and data is committed in database. Next call T2 transaction as Asynchronous call to execute CAF BO “READ” operation.
- The above solution could have potential performance impact since this change will impact many DCs and for every create/update operation an Async call has to be spawned leading to potential performance overhead.
For doing that we need to change the transaction type of the CAF Service Operation to REQUIRES_NEW.
2. Use Bean Management Transaction*
- Write Annotation @TransactionManagement(TransactionManagementType.BEAN) at the BeanImpl class
- Set autoCommit false
- Write commit explicitly at the DAO class