navigation

How to make ADF custom service method run out of JTA transaction?

How to make ADF custom service method run out of JTA transaction?

by
April 20, 2016

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

serviceinterface, AppModuleServiceImpl.java, oracle adf, adf oracle

2. In the source editor, locate the custom method that you want to prevent from timing out and place your cursor on the method.

custom method, adf oracle, oracle adf

3. In the Properties window, expand Stateless Session Bean, and then select “TransactionAttributeType.NOT_SUPPORTED” from the “TransactionAttribute” dropdown list.

Stateless Session Bean, TransactionAttribute, oracle adf, adf oracle4. 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.TransactionAttribute, source editor, oracle adf, adf oracle

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.

Denis Danov

Java EE and Oracle Developer at Dreamix

More Posts - Website

Follow Me:
TwitterLinkedInGoogle Plus

Do you want more great blogs like this?

Subscribe for Dreamix Blog now!

  • Dheeraj Sharma

    Hi Denis ,

    I have used this and it works fine . Thanks for sharing this approach . I owe you one.