spring-data-neo4j-4

SDN-4 connection pooling


I am using spring-data-neo4j 4.1.3.RELEASE with spring boot application. Using neo4j in server mode, community edition - version 3.1.0 with http driver ( would be changing to bolt driver soon)

I am using neo4j session with request scope

    @Bean
    @Override
    @Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
    public Session getSession() throws Exception {
        return super.getSession();
    }

I would like know how to enable connection pooling with http driver or bolt driver.


Solution

  • Connection pooling is enabled by default in SDN/OGM for both http and bolt driver. The default pool size is 50.

    To modify the pool size you can set following property in ogm.properties:

    connection.pool.size=50
    

    or if you use java configuration:

    OGM 2.0.x (used by SDN 4.1.x)

    org.neo4j.ogm.config.DriverConfiguration#setConnectionPoolSize
    

    OGM 2.1.x (used by SDN 4.2.x)

    org.neo4j.ogm.config.Configuration.Builder#connectionPoolSize