If there is existing doc/threads that answer this question, please point me. 10 minutes of google and forum searching hasn't turned up what I'm looking for...
I've been brought in to help a troubled team. The have a few web apps utilizing EJB 2 and running in JBoss 3.2.5. In addition to browser access, they also offer some services like PO imports and Invoice processing, both of which can be done in batches. Everthing they do runs in single, long-running transactions because they just use "Required" everywhere! So, for example, if you are bringing in a batch of PO's (one long-running transaction) and someone logs into the web (a normal length transaction), you'll start getting deadlock errors and/or timeout errors.
There's some awkward code in here. The developers learned more and more about XDoclet as they went along, but never went back and fixed anything. In a single Session Bean method, it is not uncommon to find them sitting on the Entity Bean and making some calls on it directly, while at the same time working with a "Data Object" from an entity bean AND working with a "Value Object" from an entity bean--yes, all in the same method! It's frightening.
I know the obvious steps to clean up much of this--however, I have never been faced with long-running transactions (like up to 3 minutes). Can someone describe to me or point me to a good pattern? At the beginning of a PO batch import, there are several company and user records we have to obtain--but locking them for the duration is killing the web users!
I've thought about sticking a DAO layer between the Session Beans and the Entity Beans, but I still don't know the best use of transactions to get the data we need, do the "crunching," and then update the data. Can this be done effectively with container-managed transactions? Should I modify their session beans to use bean-managed transactions? Because of their piles of kludgy code, transactions are killing me.
Basically, for these long-running processes, I need a way to: 1) Get the bits of data we need for processing--but without keeping those records locked; 2) Do all the XML work/object creation; 3) Create/update records as necessary, while keeping the record locking to as brief a period as possible.
A pattern, anyone? Thanks so much!