From: Zeppe <e.t...@gm...> - 2007-04-26 08:34:12
|
Hi, I am trying to understand the thread safety in eXist. I have read what was written before in this mailing list, but it is still unclear to me. Something is thread-safe something isn't. In which cases I should be worried when using multi-threading? I have the following setting: 1. I have one instance of XML:DB Database (accessed through xmlrpc) 2. When I need to query or update the db I call Collection.getService(), and then perform queries 3. There are multiple threads that are doing the step [2]. Which cases I should beware of? Up till know it seemed that everything works fine, no concurrency exceptions or anything. So I imply that my setting is thread-safe. But is it really so? Thanks, Zeppe |
From: Wolfgang M. <wol...@ex...> - 2007-04-26 09:46:37
|
> I have the following setting: > 1. I have one instance of XML:DB Database (accessed through xmlrpc) > 2. When I need to query or update the db I call Collection.getService(), > and then perform queries > 3. There are multiple threads that are doing the step [2]. > > Which cases I should beware of? Up till know it seemed that everything > works fine, no concurrency exceptions or anything. So I imply that my > setting is thread-safe. But is it really so? The remote XML:DB driver implementation is just a wrapper around xmlrpc calls. All the real synchronization is done on the server. However, RemoteXPathQueryService itself is not thread-safe if you need to set namespace mappings, variable declarations or serialization properties. This should not be a problem if you call Collection.getService() each time you need to execute a query: the method will return a new RemoteXPathQueryService. Creating this object should be cheap, so there's no need to cache it. Wolfgang |