Social Networking Site with Grails and Neo4j - grails

I am developing a social networking website with Grails and MYSQL DB. But I am planning to move to Neo4j DB. Grails supports complete GORM features with MYSQL. But I am sure about the same features in Neo4j. There is a Grails plugin for Neo4j which does not support some of the features that is required to support big websites. So I am planning to use the native Neo4j API. From Grails how to connect to Neo4j DB? There are two scenarios in my case.
Case 1:
Neo4j server is up and running. How to connect and perform the database transactions?
Case 2:
Neo4j server is not running. How to connect and perform the database transactions? I was able to connect using GraphDatabaseService class. But why would one need to connect to DB which is not running. What is this class GraphDatabaseService particularly used for?
I want to use the native Neo4j API to get access to maximum features. Is there a better approach to build the application.

The Grails Neo4j GORM plugin in version 2.0.0.M01 is able to run embedded mode only - so the JVM running the Grails applications spawns the database inside the same JVM. Next milestone (M02) will add support for accessing Neo4j via REST.
In case you don't want to transparently use the GORM methods to talk to Neo4j you can always use direct access by emitting Cypher statements or accessing GraphDatabaseService directly (only on embedded mode of course).

Related

How to use Neo4j bolt driver along with native Java API of an embedded neo4j db?

We have one application built using Neo4j 3.0.4 embedded db. This application is responsible to build Graph.
We have another application built using Spring Data Neo4j 4.1. This application is responsible to get the Graph db data for UI.
As we do not have the capability of using traversal API in SDN4, Is there any possibility to use native Neo4j Java API in SDN4 application?
How can we do that?
There is an embedded driver for neo4j-ogm which SDN is built on, the SDN and OGM docs have examples on how to use it.
http://docs.spring.io/spring-data/data-neo4j/docs/4.2.0.RELEASE/reference/html/#reference:configuration:driver:embedded
You can expose your Neo4j embedded application through the bolt interface (This might be 3.1+ only).
You can then start your SDN application in a separate JVM and connect to your embedded instance using the bolt driver.
Otherwise it is not possible to use an embedded instance controlled by another main and SDN embedded together.

How to connect active neo4j db from java (without REST API )?

I have installed neo4j version 1.9.5 and tried some java sample to access / write data into graphdb, but for every action the existing graph db instance is created newly using below,
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("c:/movies/moviesdb"); so is it possible to access and execute cypher query through java on active Neo4j db without REST API concept.
Note : Consider Ne04j DB is already started and running
When running Neo4j as a server process, you communicate with your DB only via REST. The other usage model is embedded. Here you're application code controls the lifecycle of the DB by using new GraphDatabaseFactory().newEmbeddedDatabase(). These two modes are distinct.

Using Rexter API to interact with Neo4j

Is there a way to interact with a neo4j graph db (running externally HA mode) via Rexter API. Neo4j's REST api is great but using Rexter makes my application completely agnostic of the remote graph db implementation stack. This will enable me to swap in other tinkerpop based graph db stacks like titan without affecting/changing my application code.
You should be able to use the Neo4jHaGraph Blueprints implementation:
https://github.com/tinkerpop/blueprints/wiki/Neo4jHa-Implementation
Here's some instructions for connecting using Rexster:
https://github.com/tinkerpop/rexster/wiki/Specific-Graph-Configurations#neo4j-high-availability-cluster

Runs multiple web application with same embedded neo4j db

It is required to run multiple application on same neo4j db. But when I try to do that, I am meeting a problem about locking.
Neo4j is locking itself when an application is using it. Multiple application can't be run.
The exception is like,
Unable to lock store [/opt/neo4j-lojika-db/neostore.relationshiptypestore.db.names], this is usually a result of some other Neo4j kernel running using the same store
Is there a way to run multiple web application with same embedded neo4j db.
Thank you!
You can't do this way. You have two options
Use Neo4j HA or
Run Neo4j in server mode rather than embedded mode. If your application is simple then you can use the REST api provided by Neo4j out of box. If your service layer is more involved then, put a service layer on top of a single Neo4j embedded instance and let each application talk to Neo4j through this service layer.

How to connect to neo4j server in spring via rmi?

How to connect to neo4j server in spring via rmi? I found http://mvnrepository.com/artifact/org.neo4j/neo4j-remote-graphdb. Is it component neo4j-remote-graphdb supported?
You can connect with that library, which is also in http://github.com/neo4j/java-rest-binding
But you shouldn't use individual operations over the wire for higher performance operations, use Cypher instead (using RestGraphDatabase.query(query, params)) with Cypher Parameters.

Resources