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 <[email protected]>
To: Andreas Weiler <[email protected]>
Cc: The Trainspotter <[email protected]>;
"[email protected]" <[email protected]>
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
<[email protected]> 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
> [email protected]
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
>
>
> _______________________________________________
> BaseX-Talk mailing list
> [email protected]
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>_______________________________________________
BaseX-Talk mailing list
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk