| How do you handle a DeadLock with JBoss ? |
| Written by F.Marchioni | |||||
|
When your application is trying to access the same entity bean within 2 different transaction in a different order a DeadLock can happen. When jBoss detects this situation will issue a org.jboss.util.deadlock.ApplicationDeadlockException. So you should write your application so that it can retry a transaction if the invocation fails because of the ApplicationDeadlockException. Unfortunately, this exception can be deeply embedded within a RemoteException, so you have to search for it in your catch block. For example:
try {
// ...
} catch (RemoteException ex) {
Throwable cause = null;
RemoteException rex = ex;
while (rex.detail != null) {
cause = rex.detail;
if (cause instanceof ApplicationDeadlockException) {
// ... We have deadlock, force a retry of the transaction.
break;
}
if (cause instanceof RemoteException) {
rex = (RemoteException)cause;
}
}
}
Remember, with a PessimisticEJBLock, Entity beans are locked until the transaction commits or is rolled back!
JBoss.org Search
Custom Search
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |


