Armin, Thanks for the reply.
Let me understand correctly. If I'm building a server application and it has 10 worker threads. Each worker does some database manipulation. Should I create a PB for each session that a worker goes to work and then close after it finish the work. The worker is pooled. Or should I create a PB for each worker for its life time?. Is PB <-> db connection one-to-one relationship? If yes, I have to use the first approach unless jdbc driver pools the connection. --Yajun ----- Original Message ----- From: "Armin Waibel" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Wednesday, June 11, 2003 1:29 AM Subject: Re: Multiple threads using one broker > Hi Yajun, > > ----- Original Message ----- > From: "Yajun Liu" <[EMAIL PROTECTED]> > To: "OJB Users List" <[EMAIL PROTECTED]>; "Armin Waibel" > <[EMAIL PROTECTED]> > Sent: Wednesday, June 11, 2003 7:10 AM > Subject: Re: Multiple threads using one broker > > > > Does closing broker close database connection? If yes, then it is too > > expensive. > > broker.close() does > - return the PB instance back to PB-pool > - close the connection, BUT 'normal' connections > are pooled too (mean con.close() return connection back > to pool) in OJB by default. > Except using DataSource. OJB does never pool > DataSources, but DataSources are handles to a real > connection (and normally they are pooled too) > > regards, > Armin > > > > > --Yajun > > > > ----- Original Message ----- > > From: "Armin Waibel" <[EMAIL PROTECTED]> > > To: "OJB Users List" <[EMAIL PROTECTED]> > > Sent: Tuesday, June 10, 2003 4:20 PM > > Subject: Re: Multiple threads using one broker > > > > > > > Hi Denis, > > > > > > ----- Original Message ----- > > > From: "Denis Avdic" <[EMAIL PROTECTED]> > > > To: "OJB Users List" <[EMAIL PROTECTED]> > > > Sent: Tuesday, June 10, 2003 9:40 PM > > > Subject: Multiple threads using one broker > > > > > > > > > > Hi, > > > > > > > > I am using OJB with Struts and I have a number of actions that use > > > > persistence broker calls to retrieve and store data. > > > > > > > > Now, if I have a number of users using the application, all users > > > share > > > > the same broker. > > > > > > PersistenceBroker instance itself is not threadsafe. For this reason > > > OJB use a PB-pool to allow a per thread handling of PB instances. > > > Mean each user should get his own PB instance. Get the broker, > > > do the work, close the broker. Or you have > > > to synchronize user action. > > > > > > regards, > > > Armin > > > > > > > Thus I get collisions where one user would begin a > > > > transaction then another would begin a transaction (and get an > > > > exception) and then first user would commit transaction, and when > the > > > > second user would try to commit transaction I get an error. > > > > > > > > What can I do to fix this, is there anything in the configuration > I > > > can > > > > do, or does anyone have a trick for this? > > > > > > > > my broker is a regular broker I get by calling > > > > PersistenceBrokerFactory.defaultPersistenceBroker(); > > > > > > > > TIA, > > > > > > > > Denis > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
