jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandru Popescu" <the.mindstorm.mailingl...@gmail.com>
Subject Re: Best practice for working with multiple sessions needed
Date Sun, 24 Sep 2006 13:30:40 GMT
On 9/24/06, Daniel Doubleday <daniel.doubleday@gmx.net> wrote:
>
> Hi all,
>
> The problem scenario is concurrent application (web)
>
> The following pseudo code tries to explain the general problem:
>
> // thread a
> Node userANode = userASession.getRootNode().getNode("somenode");
>
> // thread b
> Node userBNode = userBSession.getRootNode().getNode("somenode");
>
> // thread a
> userANode.addNode("foo");
>
> // thread b
> userBNode.addNode("bar");
>
> // thread a
> userANode.save();
>
> //thread b
> userBNode.save();
> // crash
>
> Since the node "somenode" was modified in two sessions the thread that tries
> to do the second save will fail because of the "external" modification.
>
> 1. my main problem is that I don't see an easy way of how to recover from
> such a crash. I don't even see a way to check first because ItemState is
> jackrabbit internal
> 2. I believe that in almost every webapp adding a node to some special entry
> node (such as a folder for messages) is very common.
> 3. using a shared session does not seem to be an option (synch issue)
>
> Is there some sort of best practice working with multiple sessions? Does
> this mean that one has to implement an application specific locking
> mechanism?
>
> Cheers, Daniel
>

I think for concurrent write access you should start looking into the
locking API offered by JCR. This will probably require some small code
changes (if you already have the code) or shifting a bit the way you
plan to implement it (find the parent node, lock it for write, write,
unlock).

HTH,

./alex
--
.w( the_mindstorm )p.

>
>
> --
> View this message in context: http://www.nabble.com/Best-practice-for-working-with-multiple-sessions-needed-tf2326328.html#a6471987
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message