I have a message driven bean which is processing a transaction which cam 
sometimes run for hours. The main goal I am trying to acheive is to increase 
the transaction timeout from the default 300 seconds (5 mins) to somehere in 
hours. The code below demonstrates the number of things I have tried to acheive 
this, but I have been unsuccessful in every attempt. I am starting to think 
there may be a bug in one of the transaction annotations. Please help...thanks!

- 1. Tried setting the context from setMessageDrivenContext which is called by 
the container. I then got the user transaction and tried to set that timeout to 
> 5 mins but that did not affect the 5 min default trans. timeout. (Please see 
commented code)

- 2. Tried setting the @TransactionTimeout annotation to a value > 500 but that 
seems to do nothing...bug?

- 3. Any other suggestions?

@TransactionManagement(TransactionManagementType.BEAN)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionTimeout(value=800)
public class MDBDataLoadTask implements MessageListener,MessageDrivenBean {
        private MessageDrivenContext ctx;

        public void onMessage(Message msg) 
        {
                   /*
                   UserTransaction aUT = ctx.getUserTransaction();
           aUT.begin();
           aUT.setTransactionTimeout(360);
                   */

            try
            {  
                        //Perform a task that will take about this long to run
                Thread.sleep(365000);
                //aUT.commit();         
            } 
            catch (Exception e) 
            {
                /*try{
                aUT.setRollbackOnly();}
                catch(SystemException se){System.out.println(se.toString());}*/
            }
        }
        
        @Resource
        public void setMessageDrivenContext(MessageDrivenContext ctx) {         
this.ctx = ctx; }
                
        public void ejbRemove() {ctx=null;}
}

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3951829#3951829

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3951829


_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to