[jboss-dev-forums] [EJB 3.0 Development] - achieving sub transaction

Kannan S do-not-reply at jboss.com
Mon Oct 18 14:19:00 EDT 2010


Kannan S [http://community.jboss.org/people/techy_kans] created the discussion

"achieving sub transaction"

To view the discussion, visit: http://community.jboss.org/message/567017#567017

--------------------------------------------------------------
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
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/567017#567017]

Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2030]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20101018/6313b64c/attachment.html 


More information about the jboss-dev-forums mailing list