• Post Reply Bookmark Topic Watch Topic
  • New Topic

CMT EJB method that never returns

 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let us consider the following method in a stateless session EJB having Container managed transaction demarcation with a transaction time out of
60 seconds. Due to the infinite loop the method never returns and as per documentation (weblogic) the server will not attempt to abandon the transaction.( But the transaction is marked for a rollback as demanded by EJB specification. ) Hence there is no response or exception received by the client (caller of this EJB method). Is there anyway to make the server abandon the execution of the infinite loop and log or return the Transaction Timeout Exception ?


public int add(int x, int y) {

int k=10;
while(k <100){

}

return x+y;
}
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server will indeed abandon the transaction after 60 seconds, that is the reason for the transaction timeout. Incidentally, the default is 30 seconds for WLS.
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ckarthi"

Please click on the My Profile link above and change your display name to match the JavaRanch Naming Policy of using your real first and real last names.

Thanks

Mark
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you point me to the doc which says that the transaction is marked for rollback but not abandoned.
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by karthi:
Let us consider the following method in a stateless session EJB having Container managed transaction demarcation with a transaction time out of
60 seconds. Due to the infinite loop the method never returns and as per documentation (weblogic) the server will not attempt to abandon the transaction.( But the transaction is marked for a rollback as demanded by EJB specification. ) Hence there is no response or exception received by the client (caller of this EJB method). Is there anyway to make the server abandon the execution of the infinite loop and log or return the Transaction Timeout Exception ?


public int add(int x, int y) {

int k=10;
while(k <100){

}

return x+y;
}


From the link below I understand the exception is needed thrown but the developer needs to issue the rollback on the ejbcontext

http://support.bea.com/application_content/product_portlets/support_patterns/wls/Investigating_Transaction_Problems_Pattern.html#Transaction_Timeout_and_Transaction
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The developer needs to do no rollback after timeout. WebLogic Server will rollback the transaction if it times out - that's the safe thing to do for transactions that take too long. If an attempt is made to do something without a transaction, it will not be allowed. Here is an actual example (taken from a server log file I happen to have) of what WLS sends you on an attempt to update the DB after a transaction timeout.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roger Chung-Wee:
The developer needs to do no rollback after timeout. WebLogic Server will rollback the transaction if it times out - that's the safe thing to do for transactions that take too long. If an attempt is made to do something without a transaction, it will not be allowed. Here is an actual example (taken from a server log file I happen to have) of what WLS sends you on an attempt to update the DB after a transaction timeout.


Great. This is how it should be.
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The transaction may be marked for rollback as it should be. But the server is not returning with the error message "The Transaction has timed out". This is the case with SUN ONE server too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!