You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "McCaffrey, John G." <Jo...@kraft.com> on 2003/07/11 18:43:06 UTC

Broker threading

I was wondering how most people handle getting a Broker obj. Do you get a
new one each time, or a singleton, or what?
I have a serviceLocator.findBroker() that basically returns a new one each
time. 
 PBKey pbKey = new PBKey("default");
 broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);

I see that it creates my sequenceManager for each db call, and I didn't
think I really needed to be doing that. So when you guys get a
persistenceBroker reference, are you getting a new one each time, or do you
pass around one reference? Are there threading or performance issues to be
concerned about?

Thanks for your help,
-John

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Broker threading

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,

----- Original Message -----
From: "McCaffrey, John G." <Jo...@kraft.com>
To: "'OJB Users List'" <oj...@db.apache.org>
Sent: Friday, July 11, 2003 6:43 PM
Subject: Broker threading


> I was wondering how most people handle getting a Broker obj. Do you
get a
> new one each time, or a singleton, or what?
> I have a serviceLocator.findBroker() that basically returns a new one
each
> time.
>  PBKey pbKey = new PBKey("default");
why not only create PBKey once (for the same jcdAlias)

>  broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);
>
This only obtain a broker instance from the broker-pool

> I see that it creates my sequenceManager for each db call, and I
didn't
> think I really needed to be doing that.

each PersistenceBroker instance use its own SequenceManager
instance.

> So when you guys get a
> persistenceBroker reference, are you getting a new one each time, or
do you
> pass around one reference? Are there threading or performance issues
to be
> concerned about?

PB itself is not threadsafe, thus handle one PB instance
per thread (and do PB.close() to return PB to PB-pool).

regards,
Armin

>
> Thanks for your help,
> -John
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org