Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-30-2018 03:51 PM
In older versions of Spring-Data-Neo4j it was possible to configure an embedded database, but enable remote access to it via the Neo4j-shell. This was done by using a GraphDatabaseFactory to construct a preconfigured GraphDatabaseService:
GraphDatabaseService newEmbeddedGraphDatabase(String dbDir) {
db = factory.newEmbeddedDatabaseBuilder(dbDir)
.setConfig(ShellSettings.remote_shell_enabled, "true")
.setConfig(ShellSettings.remote_shell_port, "5555")
.newGraphDatabase()
db
}
and then wire that as a dependency when initialising the spring beans:
beans {
graphDatabaseFactory(GraphDatabaseFactory)
trueDbGraphDatabaseFactory(OurGraphDatabaseFactory, graphDatabaseFactory)
graphDatabaseService(GraphDatabaseService, db) { bean ->
bean.factoryBean = "ourGraphDatabaseFactory"
bean.factoryMethod = "newEmbeddedGraphDatabase"
bean.destroyMethod = "shutdown"
}
}
I'm trying to work out how to achieve this in the new OGM project. Is it possible?
If I configure OGM using:
SessionFactory newSessionFactory() {
GraphDatabaseSettings
def configuration = new Configuration()
configuration.driverConfiguration()
.setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver")
.setURI("file:///var/tmp/neo4j.db")
new SessionFactory(configuration, "test.my.domain.path")
}
How do I inject my own instance of a GraphDatabaseService into the EmbeddedDriver? (There is a constructor to EmdeddedDriver that takes one, but it's not clear which constructor OGM is using).
08-30-2018 11:17 PM
You can configure a bolt connector for your embedded database if you have the dependencies setup.
Basically the same connector settings as in neo4j.conf
08-31-2018 02:56 AM
@michael.hunger Neo4j 2.3.x doesn't support bolt yet; but maybe I can use do the same thing with the web connector perhaps?
08-30-2018 11:46 PM
You are on the right track. You can instantiate and pre-configure a GraphDatabaseService
and handle it over to the embedded driver.
GraphDatabaseService graphDatabaseService = new GraphDatabaseFactory()
.newEmbeddedDatabase(...)
// do your configuration
.newGraphDatabase();
EmbeddedDriver driver = new EmbeddedDriver(graphDatabaseService);
SessionFactory sessionFactory = new SessionFactory(driver, "package");
08-31-2018 02:55 AM
@gerrit.meier It doesn't look like the SessionFactory() in OGM version 2.1.6 has a constructer that takes a database. :(. Maybe that was added in a later version. (I'm still on Neo4j 2.3.x so I can't move to the latest OGM yet).
08-31-2018 04:06 AM
Yes, sorry, this is only available in Neo4j-OGM 3.0+ and I have no solution for you in this case that I would recommend.
All the sessions of the conference are now available online