Database connections and object managers for use in threads

I have an xdata server with a ServerContainer (DataModule) that holds:

TXDataServer
TXDataConnectionPool
TAureliusConnection
TFDConnection

I have an OmniBackgroundWorker which manages a job queue (so Jobs in Threads).

In the jobs I need access to a TObjectManager and possibly a DataConnection. So the question is

Do the Jobs need to create their own connections?
Or is it safe to call a connection from TXDataConnectionPool.GetPoolInterface.GetConnection?
Or should I do this another way?

Thanks.

They need to use an exclusive connection for each thread, just like in the XData service operations.

Yes, it's safe, that's how it's supposed to work. Understandably you asked the two questions as if they were different things, but it's the same. Calling Pool.GetConnection will make sure that one connection from the pool will be available exclusively for you (in this case, the job queue) until it returns the connection back to the pool.

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.