How to make ADF custom service method run out of JTA transaction?
Intro: Long time has passed since I wrote about Service-enabled application modules in ADF (Creating custom web services from application module). With the time in our team we learned how to create custom service methods with custom input and output, sometimes composed of master-details view objects. Issue: But recently we faced another issue: one of our […]
Long time has passed since I wrote about Service-enabled application modules in ADF (Creating custom web services from application module). With the time in our team we learned how to create custom service methods with custom input and output, sometimes composed of master-details view objects.
Issue:
But recently we faced another issue: one of our custom service methods was taking a lot of time because there was communication with other systems and we hit session time-out.
This timeout limitation is established by the Java Transaction API (JTA). The JTA timeout setting establishes an execution boundary for service methods that by default may not exceed 30 seconds.
One of the solutions that you can do is to use the Administration Console for Oracle WebLogic Server to increase the JTA timeout setting. However, this will make the change global affecting all methods. Furthermore your method may still be slow - so there is another solution: you have to mark that method to run out of the JTA transaction. Here is how to do this:
Solution:
To make a custom method exempt from timing out, you set “TransactionAttributeType.NOT_SUPPORTED” in the Properties window specifically for that method. But there is one important point that you must know. Because a method with this transaction attribute setting will not be executed in the JTA transaction, it is your responsibility to enforce control over the transaction using the ADF Business Components methods of the “oracle.jbo.ApplicationModule” and “oracle.jbo.Transaction” interfaces. For instance, the methods of the implementation class of the application module that you service-enabled, will need to call “getDBTransaction().commit()” or “getDBTransaction().rollback()” in order to complete the transaction.
Step by Step:
1. In the Applications window, expand the application module, expand the “serviceinterface“ node, then double-click the service implementation class (AppModuleServiceImpl.java) file.
2. In the source editor, locate the custom method that you want to prevent from timing out and place your cursor on the method.
3. In the Properties window, expand Stateless Session Bean, and then select “TransactionAttributeType.NOT_SUPPORTED” from the “TransactionAttribute” dropdown list.
4. Save the service implementation class.
5. In the Applications window, double-click the application module implementation class (AppModuleImpl.java) file.
6. In the source editor, in the custom method that implements the service method that you previously set the “TransactionAttribute” property on, add the custom code that will commit and roll back the transaction.7. Save the application module implementation class.
I am interested if someone else has used this approach? If you have please share your experience if there were some downsides while using this approach.
Sign up for our newsletter and never miss an article
[mc4wp_form id=8036]
Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.