[jboss-user] [EJB 3.0] - EJB3 transaction propagation

rphadnis do-not-reply at jboss.com
Wed Aug 13 15:21:01 EDT 2008


Hello,
I need help with transactions in EJB3. 

I have an EJB which is called at a regular frequency using a timer. The EJB has a method with the @Timeout annotation. The method also specifies the REQUIRES_NEW transaction attribute. In this method, I am retrieving a list of records from the database. For each record, I am calling another method (update) in the same bean to update that record.  The update method also specifies REQUIRES_NEW transaction attribute.

What I want to know is, if the updating of all the records takes more time than the transaction time out specified in the jboss configuration, will the update of all records be rolled back ?

What seems to be happening is the list is long and it takes more than 300 seconds to do the update of all records. Once that happens none of the records get updated. But I thought by adding  the TransactionAttributeType.REQUIRES_NEW attribute on the update method, 

I am trying to specify that each record should be updated in a separate transaction. 

Here is some pseudo code:


  | @Timeout
  | @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
  |  public void updateList(Timer timer) {
  |       List<Record> list = getRecords();
  |       for (Record r : list) {
  |           update(r);
  |       }
  |       logger.log("done");
  | }
  | 
  | @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
  | private void update(Record r) {
  |     //call another webservice to get update data
  |    // set updated fields in record
  |    //call merge on the injected RecordDA
  |     recordDA.merge(r);
  | }
  | 
  | 

Please help.

Rahul Phadnis

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

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



More information about the jboss-user mailing list