REST "purists" prefer that each REST-ful invocation is atomic, but as we all know, there are definitely cases where multiple "transactions" need to be implemented.
The cleanest approach I've seen involved an explicit call to "create" a transaction/unit of work, and some type of transaction token/ID and/or URL would be returned (a new URI resource) that would be passed as part of subsequent REST-ful calls as either part of the URL or as a header. Then, the original URI resource could be used to complete/rollback the transaction [1]http://server/Neo4J/Transaction/87342342344/Commit or [2]http://server/Neo4J/Transaction/87342342344/Fail. I think Javier's proposal is similar, but what I would avoid is inferring transactions between a client and server in the way Javier describes, and instead making the transaction identifier a part of the URL or delivered as a header. I also like his approach of using well-known HTTP result codes to manage the transaction lifecycle. Rick -------- Original Message -------- Subject: Re: [Neo] Transactions in Neo4j REST Server From: Anders Nawroth <and...@neotechnology.com> Date: Thu, May 20, 2010 9:00 am To: Neo user discussions <user@lists.neo4j.org> Hi! The guys who wrote the REST component are offline at the moment, so I'll just chime in here for now. You are right that the current REST API won't allow you to control transactions: it wraps each request in a transaction. There's basically two strategies, either you keep a transaction open spanning multiple requests, or you bundle the operations together somehow and send them in a single request. It would be interesting to hear some different views on this topic from the community - what would be useful to you? /anders Javier de la Rosa wrote: > Hi all, > > I think there's no way to perform a transaction through Neo4j REST > Server. It would be great if we could emulate this behaviour using the > header Keep-Alive, some session variable or some persistence issue. > A good option can be the next (I'm guessing Neo4j isn't able to manage > several transactions simultaniously, but I don't really know): > Create transaction > POST /transaction > > Example using curl > $ curl -H Accept:application/json -X POST [3]http://localhost:9999/transaction > > Response > 201: OK, a transaction was created > 409: Transaction already in progress > > Since that moment, whatever you do will be under the transaction. When > you finish the transaction. the DELETE verb has to be invoked over > /transaction: > DELETE /transaction > > Example using curl > $ curl -X DELETE [4]http://localhost:9999/transaction > > Response > 204: OK, no content returned > 404: Transaction not found > > What do you think about this? Is it too many complicated? Is it possible? > > Best regards. > > > _______________________________________________ Neo mailing list User@lists.neo4j.org [5]https://lists.neo4j.org/mailman/listinfo/user References 1. http://server/Neo4J/Transaction/87342342344/Commit 2. http://server/Neo4J/Transaction/87342342344/Fail 3. http://localhost:9999/transaction 4. http://localhost:9999/transaction 5. https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user