Hi all
We have a unique problem in our application. We have got five to six EAR files out of which two ear files interact with the database and one EAR file is a MDB listener. Lets say one of our db interacting EAR files, which is ejb module, is, Business.EAR The following is the main way the business is implemented.
The bean name is BusinessProcessorBean.java for which we have interceptor called PreProcessingInterceptor. The following is the code in PreProcessingInterceptor.
public class PreProcessingInterceptor{ @AroundInvoke public void doPreProcessing(){ try{ 1. do some db operations 2. InvocationContext.proceed() - call the bean }catch(Exception exp){ System.out.println("Exception "+exp); }finally{ PostProcessingInterceptor ppi = new PostProcessingInterceptor(); 3.ppi.doPostProcessing(); } } }
Now we have got a problem in which there may be an exception at the end of point 1 or at the end of point 3. We want to have atleast half transaction in DB so that we can get some data from the database. I came to know that we can do nested transaction . Our bean is container managed. How do i change it to bean manage so that i can re write the java code some thing like
public class PreProcessingInterceptor{
@AroundInvoke
public void doPreProcessing(){
try{
a. transaction.begin();
1. do some db operations
b. transaction.commit();
2. InvocationContext.proceed() - call the bean
}catch(Exception exp){
System.out.println("Exception "+exp);
}finally{
PostProcessingInterceptor ppi = new PostProcessingInterceptor();
c. transaction.begin();
3.ppi.doPostProcessing();
d. transaction.commit();
}
}
}
Please guide me so that our application saves data atleast in a few tables rather than not updating any tables.
Regards
Kannan.S