Transactions in REST API

587 views
Skip to first unread message

Cyprian Kowalczyk

unread,
Mar 29, 2012, 3:35:40 AM3/29/12
to Neo4j
Hello,

I'm wondering whether it would be feasible to implement transactions
in REST API to get something like this:

Create transaction:
GET http://localhost:7474/db/data/transactions/new
Which returns transaction id. Then we can do other calls to the
transaction's URI:
* http://localhost:7474/db/data/transactions/{id}/
And the commit like this:
GET http://localhost:7474/db/data/transactions/{id}/commit
which returns transaction status.

Just a thought.

kind regards,
Cyprian

Michael Hunger

unread,
Mar 29, 2012, 3:47:01 AM3/29/12
to ne...@googlegroups.com
This is addressed in a new implementation of the http-endpoints (which is still work in progress).

https://github.com/neo4j/fast-http

Cheers

Michael

Jim Webber

unread,
Mar 29, 2012, 3:53:05 AM3/29/12
to ne...@googlegroups.com
Hi Cyprian,

The idea of letting users control transactions is controversial. Transactions are usually an implementation detail of systems, that clients shouldn't be aware of. However as a database, we might be more lenient in this case.

But in terms of your proposed message exchanges, there are some problems because you're tunnelling actions through URIs and ignoring the HTTP method.

> Create transaction:
> GET http://localhost:7474/db/data/transactions/new
> Which returns transaction id. Then we can do other calls to the
> transaction's URI:

That can't be. GET is idempotent. Creating a transaction will have to be a post to some resource and then either a direct response or a redirect followed by GET.

> * http://localhost:7474/db/data/transactions/{id}/
> And the commit like this:
> GET http://localhost:7474/db/data/transactions/{id}/commit
> which returns transaction status.

Again, GET is idempotent, it shouldn't be used like this. I'd prefer a PUT of a status over a GET to some URI.

Jim

Cyprian Kowalczyk

unread,
Mar 29, 2012, 3:09:03 PM3/29/12
to Neo4j
Good to hear this!



On Mar 29, 9:47 am, Michael Hunger <michael.hun...@neotechnology.com>
wrote:
> This is addressed in a new implementation of the http-endpoints (which is still work in progress).
>
> https://github.com/neo4j/fast-http
>
> Cheers
>
> Michael
>
> Am 29.03.2012 um 09:35 schrieb Cyprian Kowalczyk:
>
>
>
>
>
>
>
> > Hello,
>
> > I'm wondering whether it would be feasible to implement transactions
> > in REST API to get something like this:
>
> > Create transaction:
> > GEThttp://localhost:7474/db/data/transactions/new
> > Which returns transaction id. Then we can do other calls to the
> > transaction's URI:
> > *http://localhost:7474/db/data/transactions/{id}/
> > And the commit like this:
> > GEThttp://localhost:7474/db/data/transactions/{id}/commit

Nicolas Dietrich

unread,
May 4, 2012, 9:33:28 AM5/4/12
to ne...@googlegroups.com, ja...@voltvoodoo.com
Hi Michael & Jacob,

we're happy to find out about this ongoing effort of a transaction aware REST server. 

Some questions:

 * Is the intention of fast-http to replace the current neo4j-rest-server?
 * Is there any roadmap / time frame about a stable release?
 * Is it already usable?
 * Is there some installation documentation?

Thanks and cheers,
Nicolas

Jacob Hansson

unread,
May 5, 2012, 7:23:13 AM5/5/12
to Nicolas Dietrich, ne...@googlegroups.com

Sent from my phone, please excuse typos and brievety.


On May 4, 2012 3:33 PM, "Nicolas Dietrich" <nicodi...@gmail.com> wrote:
>
> Hi Michael & Jacob,
>
> we're happy to find out about this ongoing effort of a transaction aware REST server. 
>
> Some questions:
>
>  * Is the intention of fast-http to replace the current neo4j-rest-server?

No. Fast-HTTP is a prototype we built to get an idea of how much performance we can get out of HTTP, as well as sketching on extensions to the current REST API.

>  * Is there any roadmap / time frame about a stable release?

No, fast-http is not part of our planned pipeline.

>  * Is it already usable?

Kind of, basic support for node / relationship CRUD and transactions are supported.

>  * Is there some installation documentation?

No, it can be started as a java app from within eclipse, see the Neo4jServer class. See the integration tests for API syntax.

Peter Neubauer

unread,
Nov 5, 2012, 9:52:38 AM11/5/12
to Neo4j User, Nicolas Dietrich
Benjamin,
did you consider using the Batch REST endpoint to group several calls into one transaction? http://docs.neo4j.org/chunked/snapshot/rest-api-batch-ops.html

/peter


Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.8 GA - http://www.dzone.com/links/neo4j_18_release_fluent_graph_literacy.html


On Mon, Nov 5, 2012 at 4:44 AM, Benjamin Garrigues <benjamin....@gmail.com> wrote:
Hi, 
I'm planning on building a business webservice on top of a graph db , and i'm currently in the process of designing my data layer on top of neo4j.
For now, i'm using py2neo (a python lib i found which uses REST Api) and would badly need some way of performing transaction. I've had a look at the github project you mentionned, but it doesn't seem to have been updated for the last 6 months.
 
Do you have any recommendation ?

Thanks, 
Benjamin

--
 
 

Nigel Small

unread,
Nov 5, 2012, 9:56:03 AM11/5/12
to ne...@googlegroups.com, Nicolas Dietrich
Hi Benjamin

I have just replied to what I assume is your post on SO:

http://stackoverflow.com/questions/13233107/using-neo4j-server-from-python-with-transaction/13234558

Nige


--
 
 

Benjamin Garrigues

unread,
Nov 5, 2012, 10:37:58 AM11/5/12
to ne...@googlegroups.com, Nicolas Dietrich
Hi, thanks you both for your answers. I've since found the bulb library and i'm waiting for more info on that library before making my mind as to the architecture of my data layer.

I started with model get and post and found py2neo + cypher quite powerful,  but now that i'm thinking about updates, i feel like I could use the help of a more active-record like framework for managing state sync between my model and the graph db (I even started some crazy automatic persistence of native python objects on a graph using introspection, automatically mapping property names to relationships, which kind of work as long as you don't need to diff :)).




--
 
 

Nigel Small

unread,
Nov 5, 2012, 10:52:51 AM11/5/12
to ne...@googlegroups.com, Nicolas Dietrich
Incidentally, if you are working with Django, you might also want to take a look at neomodel:

https://github.com/robinedwards/neomodel

It's based on py2neo and might offer something useful in your case.

Cheers
Nige


--
 
 

Reply all
Reply to author
Forward
0 new messages