Skip to content

Commit 9566c69

Browse files
authored
Neo4j integration (helidon-io#2692)
* Neo4j integration
1 parent 0dc4b02 commit 9566c69

65 files changed

Lines changed: 3804 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bom/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,22 @@
909909
<artifactId>helidon-logging-log4j</artifactId>
910910
<version>${helidon.version}</version>
911911
</dependency>
912+
<!-- Neo4j -->
913+
<dependency>
914+
<groupId>io.helidon.integrations.neo4j</groupId>
915+
<artifactId>helidon-integrations-neo4j</artifactId>
916+
<version>${helidon.version}</version>
917+
</dependency>
918+
<dependency>
919+
<groupId>io.helidon.integrations.neo4j</groupId>
920+
<artifactId>helidon-integrations-neo4j-health</artifactId>
921+
<version>${helidon.version}</version>
922+
</dependency>
923+
<dependency>
924+
<groupId>io.helidon.integrations.neo4j</groupId>
925+
<artifactId>helidon-integrations-neo4j-metrics</artifactId>
926+
<version>${helidon.version}</version>
927+
</dependency>
912928
</dependencies>
913929
</dependencyManagement>
914930
</project>

common/common/src/main/java/io/helidon/common/FeatureCatalog.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,23 @@ final class FeatureCatalog {
499499
"Zipkin",
500500
"Zipkin tracer integration",
501501
"Tracing", "Zipkin");
502+
add("io.helidon.integrations.neo4j",
503+
FeatureDescriptor.builder()
504+
.name("Neo4j integration")
505+
.description("Integration with Neo4j driver")
506+
.path("Neo4j")
507+
.experimental(true)
508+
.nativeSupported(true));
509+
add("io.helidon.integrations.neo4j.health",
510+
FeatureDescriptor.builder()
511+
.name("Neo4j Health")
512+
.description("Health check for Neo4j integration")
513+
.path("Neo4j", "Health"));
514+
add("io.helidon.integrations.neo4j.metrics",
515+
FeatureDescriptor.builder()
516+
.name("Neo4j Metrics")
517+
.description("Metrics for Neo4j integration")
518+
.path("Neo4j", "Metrics"));
502519
add("io.helidon.webclient",
503520
FeatureDescriptor.builder()
504521
.name("Web Client")

dependencies/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<version.lib.mockito>2.23.4</version.lib.mockito>
107107
<version.lib.mongodb.reactivestreams>1.11.0</version.lib.mongodb.reactivestreams>
108108
<version.lib.mssql-jdbc>8.4.1.jre8</version.lib.mssql-jdbc>
109+
<version.lib.neo4j>4.2.0</version.lib.neo4j>
109110
<version.lib.mysql-connector-java>8.0.22</version.lib.mysql-connector-java>
110111
<version.lib.narayana>5.9.3.Final</version.lib.narayana>
111112
<version.lib.netty>4.1.59.Final</version.lib.netty>
@@ -1014,6 +1015,12 @@
10141015
<artifactId>micronaut-aop</artifactId>
10151016
<version>${version.lib.micronaut}</version>
10161017
</dependency>
1018+
<!-- Neo4j -->
1019+
<dependency>
1020+
<groupId>org.neo4j.driver</groupId>
1021+
<artifactId>neo4j-java-driver</artifactId>
1022+
<version>${version.lib.neo4j}</version>
1023+
</dependency>
10171024
<!-- END OF Section 1: direct third party dependencies -->
10181025

10191026
<!-- Section 2: third party dependencies used by examples -->
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/*
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# 1st stage, build the app
18+
FROM maven:3.6-jdk-11 as build
19+
20+
WORKDIR /helidon
21+
22+
# Create a first layer to cache the "Maven World" in the local repository.
23+
# Incremental docker builds will always resume after that, unless you update
24+
# the pom
25+
ADD pom.xml .
26+
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip
27+
28+
# Do the Maven build!
29+
# Incremental docker builds will resume here when you change sources
30+
ADD src src
31+
RUN mvn package -DskipTests
32+
RUN echo "done!"
33+
34+
# 2nd stage, build the runtime image
35+
FROM openjdk:11-jre-slim
36+
WORKDIR /helidon
37+
38+
# Copy the binary built in the 1st stage
39+
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp.jar ./
40+
COPY --from=build /helidon/target/libs ./libs
41+
42+
CMD ["java", "-jar", "helidon-examples-integration-neo4j-mp.jar"]
43+
44+
EXPOSE 8080
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# 1st stage, build the app
18+
FROM maven:3.6.3-jdk-11-slim as build
19+
20+
WORKDIR /helidon
21+
22+
# Create a first layer to cache the "Maven World" in the local repository.
23+
# Incremental docker builds will always resume after that, unless you update
24+
# the pom
25+
ADD pom.xml .
26+
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip
27+
28+
# Do the Maven build to create the custom Java Runtime Image
29+
# Incremental docker builds will resume here when you change sources
30+
ADD src src
31+
RUN mvn -Ddocker.build=true package -Pjlink-image -DskipTests
32+
RUN echo "done!"
33+
34+
# 2nd stage, build the final image with the JRI built in the 1st stage
35+
36+
FROM debian:stretch-slim
37+
WORKDIR /helidon
38+
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp-jri ./
39+
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"]
40+
EXPOSE 8080
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# 1st stage, build the app
18+
FROM helidon/jdk11-graalvm-maven:20.2.0 as build
19+
20+
WORKDIR /helidon
21+
22+
# Create a first layer to cache the "Maven World" in the local repository.
23+
# Incremental docker builds will always resume after that, unless you update
24+
# the pom
25+
ADD pom.xml .
26+
RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip
27+
28+
# Do the Maven build!
29+
# Incremental docker builds will resume here when you change sources
30+
ADD src src
31+
RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests
32+
33+
RUN echo "done!"
34+
35+
# 2nd stage, build the runtime image
36+
FROM scratch
37+
WORKDIR /helidon
38+
39+
# Copy the binary built in the 1st stage
40+
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp .
41+
42+
ENTRYPOINT ["./helidon-examples-integration-neo4j-mp"]
43+
44+
EXPOSE 8080
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Helidon Quickstart MP Example
2+
3+
This example implements a simple Neo4j REST service using MicroProfile.
4+
5+
## Build and run
6+
7+
Bring up a Neo4j instance via Docker
8+
9+
```bash
10+
docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:4.0
11+
```
12+
13+
Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies).
14+
15+
16+
Then build with JDK11+
17+
```bash
18+
mvn package
19+
java -jar target/helidon-integrations-neo4j-mp.jar
20+
```
21+
22+
## Exercise the application
23+
24+
```
25+
curl -X GET http://localhost:8080/movies
26+
27+
```
28+
29+
## Try health and metrics
30+
31+
```
32+
curl -s -X GET http://localhost:8080/health
33+
{"outcome":"UP",...
34+
. . .
35+
36+
# Prometheus Format
37+
curl -s -X GET http://localhost:8080/metrics
38+
# TYPE base:gc_g1_young_generation_count gauge
39+
. . .
40+
41+
# JSON Format
42+
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
43+
{"base":...
44+
. . .
45+
46+
```
47+
48+
## Build the Docker Image
49+
50+
```
51+
docker build -t helidon-integrations-neo4j-mp .
52+
```
53+
54+
## Start the application with Docker
55+
56+
```
57+
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp:latest
58+
```
59+
60+
Exercise the application as described above
61+
62+
## Deploy the application to Kubernetes
63+
64+
```
65+
kubectl cluster-info # Verify which cluster
66+
kubectl get pods # Verify connectivity to cluster
67+
kubectl create -f app.yaml # Deploy application
68+
kubectl get service helidon-integrations-neo4j-mp # Verify deployed service
69+
```
70+
71+
## Build a native image with GraalVM
72+
73+
GraalVM allows you to compile your programs ahead-of-time into a native
74+
executable. See https://www.graalvm.org/docs/reference-manual/aot-compilation/
75+
for more information.
76+
77+
You can build a native executable in 2 different ways:
78+
* With a local installation of GraalVM
79+
* Using Docker
80+
81+
### Local build
82+
83+
Download Graal VM at https://www.graalvm.org/downloads. We recommend
84+
version `20.1.0` or later.
85+
86+
```
87+
# Setup the environment
88+
export GRAALVM_HOME=/path
89+
# build the native executable
90+
mvn package -Pnative-image
91+
```
92+
93+
You can also put the Graal VM `bin` directory in your PATH, or pass
94+
`-DgraalVMHome=/path` to the Maven command.
95+
96+
See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-native-image
97+
for more information.
98+
99+
Start the application:
100+
101+
```
102+
./target/helidon-quickstart-mp
103+
```
104+
105+
### Multi-stage Docker build
106+
107+
Build the "native" Docker Image
108+
109+
```
110+
docker build -t helidon-integrations-neo4j-mp-native -f Dockerfile.native .
111+
```
112+
113+
Start the application:
114+
115+
```
116+
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-native:latest
117+
```
118+
119+
120+
## Build a Java Runtime Image using jlink
121+
122+
You can build a custom Java Runtime Image (JRI) containing the application jars and the JDK modules
123+
on which they depend. This image also:
124+
125+
* Enables Class Data Sharing by default to reduce startup time.
126+
* Contains a customized `start` script to simplify CDS usage and support debug and test modes.
127+
128+
You can build a custom JRI in two different ways:
129+
* Local
130+
* Using Docker
131+
132+
133+
### Local build
134+
135+
```
136+
# build the JRI
137+
mvn package -Pjlink-image
138+
```
139+
140+
See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-jlink-image
141+
for more information.
142+
143+
Start the application:
144+
145+
```
146+
./target/helidon-integrations-neo4j-mp-jri/bin/start
147+
```
148+
149+
### Multi-stage Docker build
150+
151+
Build the JRI as a Docker Image
152+
153+
```
154+
docker build -t helidon-integrations-neo4j-mp-jri -f Dockerfile.jlink .
155+
```
156+
157+
Start the application:
158+
159+
```
160+
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-jri:latest
161+
```
162+
163+
See the start script help:
164+
165+
```
166+
docker run --rm helidon-integrations-neo4j-mp-jri:latest --help
167+
```

0 commit comments

Comments
 (0)