java ee - Avoiding timeout on container-managed EntityManager -
i have j2ee application beans have container-managed entitymanager's. in long running method calls, trying merge info throws
rollbackexception (timed out)
i have tried using entitymanagerfactory doesn't seem allowed:
cannot utilize entitytransaction while using jta
how can run arbitrarily long processes without setting unreasonable timeout? can't jta create new transaction when needed?
following comments question, question , documentation here, solved problem using container-managed entitymanager , transactionattributetype
annotations.
the bean method caused timeout multiple calls different method handles subtask, such each method phone call executes within different transaction. utilize not_supported
attribute type since:
if client not associated transaction, container not start new transaction before running method.
with arrangement, smaller processdoc
method creates transactions shouldn't timeout.
public class mybean { @ejb private docsbean docsbean; /** * method transaction risks timeout * no transaction created not_supported */ @transactionattribute(transactionattributetype.not_supported) public void longrunning(list<document> docs) { (document doc : docs) { // different transaction used each element docsbean.processdoc(doc); } } } public class docsbean { /** runs within new transaction */ @transactionattribute(transactionattributetype.requires_new) public void processdoc(document document) { // takes time under timeout // ... } }
.
java-ee jpa ejb jta oc4j
No comments:
Post a Comment