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.
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:
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.
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.