You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hibersap-ejb library implements the HibersapSession annotation and HibersapSessionInterceptor which can be used to automatically inject a Hibersap session into an EJB. With this approach, the application developer is responsible for opening and closing transactions on the session in order to commit/rollback the transactions in SAP.
JavaEE offers a transaction synchronization mechanism where a javax.transaction.Synchronization implementation can be added to the current exception which will be notified when a transaction is completed, i.e. right after the Tx manager committed or rolled back the other resources.
Additionally, the synchronization mechanism gives the possibility to store data in a transaction context, which should be used here to store a Hibersap session for later use in the HibersapSessionInterceptor, when the Hibersap sessions need to be committed or rolled back. Now the sessions are stored in the context data of the InvocationContext. The transaction context is a much better place, since it behaves correctly even with nested transactions.
The Hibersap EJB component shall make use of this by registering a Synchronization object with every transaction where a HibersapSessionInterceptor is used and store the Hibersap sessions in the transaction context. After the container has completed a transaction, the synchronization object shall commit or rollback the Hibersap transaction which effectively will commit or rollback the transaction in SAP.
This is not a watertight transactional approach since it is still possible that a commit in SAP fails while at this point the other resources that take part in the (distributed) transaction are already committed. However, for most use cases this should be sufficient. If real distributed transactions are needed, application developers should consider using a resource adapter for SAP, like the Cuckoo RA.
The text was updated successfully, but these errors were encountered:
The hibersap-ejb library implements the HibersapSession annotation and HibersapSessionInterceptor which can be used to automatically inject a Hibersap session into an EJB. With this approach, the application developer is responsible for opening and closing transactions on the session in order to commit/rollback the transactions in SAP.
JavaEE offers a transaction synchronization mechanism where a javax.transaction.Synchronization implementation can be added to the current exception which will be notified when a transaction is completed, i.e. right after the Tx manager committed or rolled back the other resources.
Additionally, the synchronization mechanism gives the possibility to store data in a transaction context, which should be used here to store a Hibersap session for later use in the HibersapSessionInterceptor, when the Hibersap sessions need to be committed or rolled back. Now the sessions are stored in the context data of the InvocationContext. The transaction context is a much better place, since it behaves correctly even with nested transactions.
The Hibersap EJB component shall make use of this by registering a Synchronization object with every transaction where a HibersapSessionInterceptor is used and store the Hibersap sessions in the transaction context. After the container has completed a transaction, the synchronization object shall commit or rollback the Hibersap transaction which effectively will commit or rollback the transaction in SAP.
This is not a watertight transactional approach since it is still possible that a commit in SAP fails while at this point the other resources that take part in the (distributed) transaction are already committed. However, for most use cases this should be sufficient. If real distributed transactions are needed, application developers should consider using a resource adapter for SAP, like the Cuckoo RA.
The text was updated successfully, but these errors were encountered: