File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes TransactionAttribute - what's the right setting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "TransactionAttribute - what Watch "TransactionAttribute - what New topic

TransactionAttribute - what's the right setting

biking fool

Joined: Oct 18, 2013
Posts: 1
We have a process sometimes creates an email showing all zeros in the stats even though that's not truly what's on the database.

The process works like this
1. User selects a spreadsheet.
2. User hits the button to start the load/calculations and that timestamp is captured. (start_tsp)
3. Load occurs
4. Calculations occur
5. Timestamp is captured (end_tsp)
6. Email details are compiled by querying the tables loaded. Criteria for those queries is the user's lid and maint timestamp between the start_tsp and end_tsp)
7. Email is sent

Everything works fine most of the time, but occasionally, the queries from step 6 return nothing.
I added logging to verify the queries have the correct lid and timestamps. Running the same query in SQL Nav afterwards shows rows for the lid between the timestamps.
This has happened only in our Production environment. We can't recreate it in Test or even make it happen consistantly in Prod. (We've had the user reload the same spreadsheet after getting the 0's and it'll work the second time.)

One of our tech guys suggested that the TransactionAttribute could be the problem. Here's how that's set:

* Session Bean implementation class NTBServiceImpl Must be marked not supported
* so that it does not timeout
public class NtbServiceImpl implements NtbService {

He's recommending it be changed to REQUIRED or REQUIRES_NEW. But, note that the comment is saying it's set to NOT_SUPPORTED so it won't timeout. Tech guy isn't sure what will happen then.
This process takes 1-2 minutes real time so timeout is a possibility.

Should I change the attribute? If so, to what?

Thanks for the help.

PS. I'm new to this transaction stuff, so please explain in '... for dummies' language.
Dieter Quickfend

Joined: Aug 06, 2010
Posts: 543

In JBoss, you can use the @TransactionTimeout annotation... If not, check your server documentation to change the Transaction Timeout on that specific method, or in general.

But not using a transaction to circumvent the timeout is not a good practice.

Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
I agree. Here's the link:
subject: TransactionAttribute - what's the right setting
jQuery in Action, 3rd edition