I have a session bean that is called from a Message bean, and starts by getting a collection of CMP entities and then calling a method on each one. This method may take 5-10 minutes to run its course.
The purpose of this method is to gather data in the system and publish out this data in external files. Very little information is changed in the database.
I have to have a valid transactional context in this first method that is called, as it is using a CMR collection to gather the object, and the container throws an exception if I try and denote this method's container-transaction as "NotSupported".
I've gone and increased greatly the default transaction timeout, but am wondering if this is the best solution. Does having a transactional context present from beginning to end mean that a lot of system resources will be consumed, or does the overhead of the transaction only increase as I modify the data store?
If the latter case is true, could I use a RequiresNew for the method that updates the occasional CMP entity, and then if there is an error, those entities will not be rolled back?
In other words, if the original transactional context is suspended while a new transaction is created and then committed, will an error later on down the line roll back each of those updates?