TZConnection concurrency questions

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
jaodin
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 17.10.2008, 17:36

TZConnection concurrency questions

Post by jaodin »

Hello,
i can't seem to be able to find an answer to a couple of scenarios regarding concurrent queries and multithreaded application.

1) A SELECT query is open and i want to execute another query (INSERT/UPDATE/DELETE) do i need to use a different TZConnection object? Of course i use different TZQuery objects for those queries. The scheme of the calling is for example:
Object1.MethodX -> Q1 := TZQuery.Create -> Q1.Open -> Q1.Next -> Call Object2.MethodY -> Q2 := TZQuery.Create -> Q2.ExecSQL -> Return to Object1.MethodX -> Q1.Next

2) A SELECT query is open concurently from a TTimer handler - do i need to use a different TZConnection object? Again, the TZQuery object is localy instanied in the handler. The call scheme could be for example:
TTimer.OnTimerHandler -> Q1 := TZQuery.Create -> Q1.Open -> Q1.Next -> DoSthWhichTakesALongTime -> TTimer.OnTimerHanlder (second run) -> Q1 := TZQuery.Create -> Q1.Open -> ... Q1.Close -> End of second run -> Q1.Next -> Q1.Close -> End of first run of timer handler.

3) Can the same TZConnection object be used from multiple threads?

To make things clear - the application is a windows service and has no gui (appart from the mandatory hidden form and timer which invokes one single method - it's pure one way communication). However it uses the database (PostgreSQL) heavily (hundreds of queries per minute). My heart is set to use persistent connections and minimize number of them, so that's basically why i'am asking ;)
Thanks in advance for any help.

Regards,
Ondrej
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

You need to use multiple TZConnections for concurrent queries. I've done it in a similar application to the one you describe and it works very well.

Ben
Post Reply