I'm using jboss 4.2.3. I use a stateful session bean to perform a long and complex operation on the entities that can require a lot of database accesses and other operations for each entity.
The stateful session bean has a few methods to setup the operation: one is to select the set of entities to process, one is to set the number of "batches" and one to set the "batch" size.
Then there's a method that when called performs the operation on a subset of the specified size of the selected entities. This method uses flush and clear method of the entity manager to flush changes to disk. This method is called from the client once for each "batch".
This bean is called from a java app, a sort of batch app that runs once a week. It simply select the number of batches and their size and then it calls the main method of the bean with a for loop.
The entire job on my actual data set runs for about 40 minutes.
At the end of the process I get an exception, a transaction timeout.
Now I suspect that using the standard transaction configuration, the transaction starts when the batch app calls the first bean method and it ends when the app destroy the bean. Since the actual jboss tx timeout is set to 600 seconds this makes the session bean timeout.
What's the best transaction configuration for the bean ? Should I set all "setup" methods to Never and the main method of the bean to requires new ? Or should I set all to Never ? Any other hint ?
Thank you for your help.