Transaction taking too long - Session Facade, CMP, JBoss

Discussions

EJB programming & troubleshooting: Transaction taking too long - Session Facade, CMP, JBoss

  1. Hi guys,

      Here is my problem:
      I have a table A and a CMP a reading data from it. Inside this table I have two columns of interest: dateFrom and dateTo.
      I have CMP b writing data inside table B. b is using bean a in order to get dateFrom and dateTo and FOR EACH DAY between these dates b creates a record inside table B.
      When the records inside A are a number 100 it all works fine. But if the records number iside A increases my transaction times out. Imagine just 100 records with dateFrom=1/1/2003 and dateTo=7/1/2003. I have to create for each record around 180 records, so the total number of records created inside B when A has 100 records is 100*180=18000. A pretty big one. My transaction times out before creating all these records.
      I order for the transaction not to time out I thought that I shouldn't use a big transaction and I should split everything in little transactions. For example a transaction should begin when reading a record from A and end when all the records corresponding to the A row are created inside B.
      But, I have to centralize this in a method in which I should call the method that runs inside the transaction described above. But the main method can't be inside a transaction because it would timeout.
      So how can I call several times a method that runs in a transaction from a method that does not run in a transaction.
      Both methods are in the same Session Bean.
      It's really messy the way I described it, but I hope you got the picture.

      If anyone sees any (other) solution please share it with us.
      Thankyou.
  2. You should not have to split the big transaction into little transactions, if one big one is what your design calls for.

    JBoss has a default transaction timeout of 300 seconds, which you should change.

    -Peris
  3. The problem is that you are running up against the EJB pool limits of your environment. You probably have a pool limit of 100 Entity beans. When your transaction involves more beans than that, the transaction cannot be completed because the EJB server cannot create enough CMP beans in memory to handle it.

    Some options:

    1) Increase the Entity pool size. This does not really solve the problem, but may be good enough for a temporary fix.

    2) Don't perform this operation using CMP beans. Put the logic into a Session bean, and perform your operations using JDBC. If you are simply transfer data from one table to another, you can probably write optimized SQL that performs this operation much more effeciently than a CMP. Talk to you DBA or consult an SQL book about how to do it.
  4. Thanks guys.
  5. CMP mapping[ Go to top ]

    I usually get this message (transaction timeout) when using
    CMP2 entity beans, if my mapping is wrong, of the entity beans
    to the db schema. For instance on a 1->1 relationship, I
    map the primary key to primary key, instead of foreign key to
    primary key.