Thanks, Johan.

My concern relates to the "transaction interleaving" that might
occur...which could definitely result in unexpected consequences, could it
not?

If I create a transaction on a specific thread, can I safely assume that it
is independent from a transaction that is started on another thread?  In
general, each servlet request will be handled on a separate thread, and we
will have a background pool of worker threads for other tasks, all of which
will occasionally need to access Neo.

I just want to make sure I fully understand the transactioning model and its
implications.

Rick

-----Original Message-----
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On
Behalf Of Johan Svensson
Sent: Wednesday, December 16, 2009 4:49 AM
To: Neo user discussions
Subject: Re: [Neo] Best practices for using Neo within a web application

Hi,

On Tue, Dec 15, 2009 at 2:44 PM, Rick Bullotta
<rick.bullo...@burningskysoftware.com> wrote:
> Hello, all.
>
> I was wondering if there was any guidance/best practices for leveraging
Neo
> in a scenario where multiple servlets in a web application will have the
> need to read/insert/update/delete nodes and relationships simultaneously.
>

We are working at getting such information up on the wiki (there are
some info but it is spread out over different pages and needs to be
completed/updated).

> In particular:
>
>
>
> 1)      Must/should the NeoService be a singleton shared amongst all
> servlets?

Yes or better is not to have singletons and instead use inversion of
control and inject the NeoService where it is needed.

>
> 2)      When best to create transactions - on each invocation?
>

Wrap each request in a transaction, this work well in most scenarios.

> 3)      How do the threading implications of the servlet's service()
method
> affect transactions and unintentional transaction nesting?

Should be no problem since trying to start a transaction when there is
already one running will do nothing and use the current running
transaction. See http://wiki.neo4j.org/content/Neo_Transactions (flat
nested transactions).

>
> 4)      Is there any advantage to using additional EmbeddedReadOnlyNeo
> instances in cases where access is truly read only?
>

No. If on the same JVM pass around the normal EmbeddedNeo instance to
read only requests also.

>
>
> In some cases, there may be a desire to have multiple web applications in
> the same web app server (Tomcat, JBoss, etc.) accessing a common Neo graph
> structure.  In this case, what are the options?  We were thinking that the
> only option is RemoteNeo between the web apps, or some other RPC layer
> invoking methods in classes that reside in the "master" web app that
> actually has a NeoService instance.
>

Was a while since I worked with Tomcat/JBoss but I take it the problem
you have is that each web app has its own class loader? If you somehow
could put the Neo4j classes and dependencies on a common class loader
used by all web apps that problem should go away (but I don't really
know this kind of stuff, anyone else?).

Regards,
-Johan
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to