Holding up connections for a transactions

Discussions

EJB design: Holding up connections for a transactions

  1. Holding up connections for a transactions (2 messages)

    Hello

    I have the following scenario with me

    There are two different session beans that have methods to insert into two different tables after taking a connection from the container's connection pool. These two beans can be called by the users through two different jsp pages

    There is another session bean that incorporates some functionality of inserting into a third table with the help of a connection. It also includes inserting data into the above two tables. Now this session bean after doing the necessary work, calls the above two session beans. The
    whole sequnce is in a transaction.

    In this case, will there be three connections held up till the time the transaction is over. How do I address this issue? I do not want to hold up so many connections as the number of hits per minute in the product we are developing is very high, and it means that we might have to have
    a very large connection pool. What are the alternatives for me to use only one connection per transaction?

    Thanks and Regards
    Sreehari

  2. Hi,
    My understanding is a transaction properties are set on a connection. So if you have a transaction spanning three connections then you need a tranaction manager like tuxedo to manage your transaction.
  3. Yes,it is distributed transaction, and the container will
    act as transaction manager, but it is expensive and have other consequences you may not expect.
    To avoid the problem, one solution might be:
    Instead of putting logic in the session bean,put it in
    seperate class and use session bean as facade
    to those pure java class.
    SB_A
    {
       getConnection(conn);
       a(conn);
       releaseConnection(conn);
    };
    SB_B
    {
       getConnection(conn);
       b(conn);
       releaseConnection(conn);
    };

    SB_C
    {
       getConnection(conn);
       a(conn);
       b(conn);
       releaseConnection(conn);
    };