Quarkus, Helidon, Micronaut
For Java developers who use Quarkus, Helidon or Micronaut and want to take advantage of a pre-configured Java driver instance. This page should give an overview of the existing support for the driver in other Java frameworks. Please consult the linked documentations for more information.
Intermediate
Driver integration
The goal with all three integrations is to provide support for getting a managed instances of the Neo4j driver. Like in the Spring Framework, you can provide the driver properties to an application.properties file (or yaml) to configure your application. In the end you will have an injectable driver instance that can be used with
@Inject
Driver driver;
in the business operation code base.
Additional to the managed driver bean creation, the integrations also expose health metrics for the driver and connection to your Neo4j instance.
Quarkus
In an existing Quarkus application you need to add the quarkus-neo4j
dependency to your project.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-neo4j</artifactId>
</dependency>
Additionally configure the basic connection parameters as needed.
quarkus.neo4j.uri = bolt://localhost:7687
quarkus.neo4j.authentication.username = neo4j
quarkus.neo4j.authentication.password = secret
If you want to make use of the health check, the additional quarkus-smallrye-health
dependency is needed.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
For metrics support, you would either need MicroMeter (recommended by Quarkus) or SmallRye Metrics (only if you really need MicroProfile specification) dependencies declared.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
The metrics for Neo4j have to be manually enabled in the application.properties.
quarkus.neo4j.pool.metrics-enabled = true
Helidon
In a Helidon-based application you need to declare the Neo4j Java driver dependency in your Maven pom.xml.
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j</artifactId>
<version>${helidon.version}</version>
</dependency>
Providing the essential connection parameters will give you a managed instance of the Java driver.
neo4j.uri = bolt://localhost:7687
neo4j.authentication.username = neo4j
neo4j.authentication.password = secret
# Enable metrics
neo4j.pool.metricsEnabled = true
If you want to use the health and metrics system, you have to also declare those dependencies provided by the Helidon framework.
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-health</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.neo4j</groupId>
<artifactId>helidon-integrations-neo4j-metrics</artifactId>
<version>${helidon.version}</version>
</dependency>
Now you can put together the configuration
Neo4JSupport neo4j = Neo4JSupport.builder()
.config(config)
.helper(Neo4JMetricsSupport.create())
.helper(Neo4JHealthSupport.create())
.build();
Routing.builder()
.register(health)
.register(metrics)
.register(movieService)
.build();
and get the managed driver bean.
Micronaut
To enable the Neo4j Driver support in Micronaut, the micronaut-neo4j-bolt dependency needs to get declared.
<dependency>
<groupId>io.micronaut.neo4j</groupId>
<artifactId>micronaut-neo4j-bolt</artifactId>
</dependency>
Adding the needed connection parameters to the application.properties.
neo4j.uri = bolt://localhost:7687
neo4j.username = neo4j
neo4j.password = secret
The module will automatically add its information to the built-in /health endpoint.
Was this page helpful?