Hi Gary,
if you want to deal with concurrency issues, you'll indeed have to stick with one single context. What you can do, however, is to explicitly register a process, as I've shown in the mail to Rainer just a minute ago.
Best, Christian ___________________________
Thank-you both. I'm currently creating new context before executing queries on the local database and it seems to be handling the concurrency well already, but I guess I may have just been lucky so far. I'll add the LocalSession bit and see how that works out.
Cheers Gary ________________________________ From: Christian Grün christian.gruen@gmail.com To: Andreas Weiler andreas.weiler@uni-konstanz.de Cc: The Trainspotter wys01@btinternet.com; "basex-talk@mailman.uni-konstanz.de" basex-talk@mailman.uni-konstanz.de Sent: Tuesday, 23 October 2012, 12:55 Subject: Re: [basex-talk] Best practices for concurrency
Hi Gary,
as Andreas mentioned, the server approach will ensure that all operations will be concurrently handled. An alternative, however, is to create a LocalSession instance, which provides the same interface and functionality as the ClientSession class, but does not rely on a database server. A little example (I hope I didn't introduce any typos):
Context ctx = new Context(); LocalSession ls = new LocalSession(ctx); ls.execute(new CreateDB("db", "<a/>")); System.out.println(ls.execute(new XQuery("db:open('db')"))); ctx.close();
Best, Christian ___________________________
On Sun, Oct 21, 2012 at 12:42 PM, Andreas Weiler andreas.weiler@uni-konstanz.de wrote:
Hi Gary,
best approach is to run a local server and then use client sessions. If you dont want to run a server, you need one seperate context for each thread.
-- Andreas
Am 20.10.2012 um 17:53 schrieb The Trainspotter:
Hi,
I've read through the online example on server concurrency, however, currently I'm not running a BaseXServer instance I'm just running things locally. I want multiple threads in my application to be able to query the database at once without treading on each others toes. What's the best approach for doing this?
I have tried querying the database using different threads but I keep getting internal BaseX errors which leads me to think I'm going about this the wrong way.
Cheers Gary _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk