Skip to content

Commit be3dfdf

Browse files
committed
Merge branch 'main' of github.com:JNOSQL/demo-ee
2 parents 43435cd + 5793ef0 commit be3dfdf

Some content is hidden

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

57 files changed

+3337
-2
lines changed

README.adoc

+14-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ Open Liberty is a lightweight and highly flexible open-source application server
2727
|Simple CRUD REST application with *Jakarta Bean Validation* support
2828
| MongoDB
2929

30+
| link:microprofile-liberty-redis-single-node/[]
31+
| Simple CRUD REST application
32+
| Redis - Single node
33+
34+
| link:microprofile-liberty-redis-sentinel/[]
35+
| Simple CRUD REST application
36+
| Redis - Sentinel
37+
38+
| link:microprofile-liberty-redis-cluster/[]
39+
| Simple CRUD REST application
40+
| Redis - Cluster
41+
3042
|===
3143

3244
== Wildfly
@@ -85,4 +97,5 @@ Apache TomEE is a lightweight, open-source Jakarta EE application server that is
8597
| Simple CRUD REST application
8698
| MongoDB
8799

88-
|===
100+
|===
101+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target/
2+
!target/*.war
3+
!target/liberty/wlp/usr/shared/resources/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
release.properties
7+
dependency-reduced-pom.xml
8+
buildNumber.properties
9+
.mvn/timing.properties
10+
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
11+
.mvn/wrapper/maven-wrapper.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
FROM icr.io/appcafe/open-liberty:kernel-slim-java21-openj9-ubi-minimal
3+
4+
COPY --chown=1001:0 /src/main/liberty/config /config
5+
6+
RUN features.sh
7+
8+
COPY --chown=1001:0 target/*.war /config/apps
9+
10+
RUN configure.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
= MicroProfile Open Liberty with Redis Cluster sample
2+
3+
This project is intent to be a sample for MicroProfile with Redis Cluster integration by using Jakarta NoSQL implementation.
4+
5+
== Setup Redis
6+
7+
image::https://jnosql.github.io/img/logos/redis.png[Redis Project,align="center" width=25%,height=25%]
8+
9+
https://redis.com/[Redis] is a software project that implements data structure servers.
10+
It is open-source, networked, in-memory, and stores keys with optional durability.
11+
12+
The project is configured to reach out the Redis Cluster with the following configuration defined on the file `src/main/resources/META-INF/microprofile-config.properties`. More info about it, check the following link: https://github.com/eclipse/jnosql-databases?tab=readme-ov-file#configuration-14
13+
14+
[source,properties]
15+
----
16+
include::src/main/resources/META-INF/microprofile-config.properties[]
17+
----
18+
*PS:warning:* Pay attention to that when you try to set up your own Redis instance.
19+
20+
== Using Docker Compose
21+
22+
The easier way to execute this project is to use the provided docker-compose.yaml file in the root directory.
23+
You can run it by performing the following command:
24+
25+
[source, bash]
26+
----
27+
docker-compose up -d
28+
----
29+
30+
== Run the code
31+
32+
The generation of the executable jar file can be performed by issuing the following command
33+
[source, bash]
34+
----
35+
mvn clean package
36+
----
37+
38+
This will create an executable jar file **microprofile-liberty-redis.jar** within the _target_ maven folder. This can be started by executing the following command
39+
40+
[source, bash]
41+
----
42+
java -jar target/microprofile-liberty-redis.jar
43+
----
44+
45+
=== Liberty Dev Mode
46+
47+
During development, you can use Liberty's development mode (dev mode) to code while observing and testing your changes on the fly.
48+
With the dev mode, you can code along and watch the change reflected in the running server right away;
49+
unit and integration tests are run on pressing Enter in the command terminal; you can attach a debugger to the running server at any time to step through your code.
50+
51+
[source, bash]
52+
----
53+
mvn liberty:dev
54+
----
55+
56+
57+
58+
59+
To launch the test page, open your browser at the following URL
60+
61+
[source, text]
62+
----
63+
http://localhost:9080/index.html
64+
----
65+
66+
67+
=== Specification examples
68+
69+
By default, there is always the creation of a JAX-RS application class to define the path on which the JAX-RS endpoints are available.
70+
71+
Also, a simple Hello world endpoint is created, have a look at the class **HelloController**.
72+
73+
More information on MicroProfile can be found [here](https://microprofile.io/)
74+
75+
76+
=== Config
77+
78+
Configuration of your application parameters. Specification [here](https://microprofile.io/project/eclipse/microprofile-config)
79+
80+
The example class **ConfigTestController** shows you how to inject a configuration parameter and how you can retrieve it programmatically.
81+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
After you generate a starter project, these instructions will help you with what to do next.
2+
3+
The Open Liberty starter gives you a simple, quick way to get the necessary files to start building
4+
an application on Open Liberty. There is no need to search how to find out what to add to your
5+
Maven build files. A simple RestApplication.java file is generated for you to start
6+
creating a REST based application. A server.xml configuration file is provided with the necessary
7+
features for the MicroProfile and Jakarta EE versions that you previously selected.
8+
9+
If you plan on developing and/or deploying your app in a containerized environment, the included
10+
Dockerfile will make it easier to create your application image on top of the Open Liberty Docker
11+
image.
12+
13+
1) Once you download the starter project, unpackage the .zip file on your machine.
14+
2) Open a command line session, navigate to the installation directory, and run `./mvnw liberty:dev` (Linux/Mac) or `mvnw liberty:dev` (Windows).
15+
This will install all required dependencies and start the default server. When complete, you will
16+
see the necessary features installed and the message "server is ready to run a smarter planet."
17+
18+
For information on developing your application in dev mode using Maven, see the
19+
dev mode documentation (https://openliberty.io/docs/latest/development-mode.html).
20+
21+
For further help on getting started actually developing your application, see some of our
22+
MicroProfile guides (https://openliberty.io/guides/?search=microprofile&key=tag) and Jakarta EE
23+
guides (https://openliberty.io/guides/?search=jakarta%20ee&key=tag).
24+
25+
If you have problems building the starter project, make sure the Java SE version on your
26+
machine matches the Java SE version you picked from the Open Liberty starter on the downloads
27+
page (https://openliberty.io/downloads/). You can test this with the command `java -version`.
28+
29+
Open Liberty performs at its best when running using Open J9 which can be obtained via IBM Semeru
30+
(https://developer.ibm.com/languages/java/semeru-runtimes/downloads/). For a full list of supported
31+
Java SE versions and where to obtain them, reference the Java SE support page
32+
(https://openliberty.io/docs/latest/java-se.html).
33+
34+
If you find any issues with the starter project or have recommendations to improve it, open an
35+
issue in the starter GitHub repo (https://github.com/OpenLiberty/start.openliberty.io).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
version: '3'
2+
3+
services:
4+
redis-configurer:
5+
container_name: "redis-configurer"
6+
image: redis:6.0-alpine
7+
command: >
8+
sh -c 'echo yes | redis-cli -h 172.22.0.2 -p 6379 --cluster create \
9+
172.22.0.2:6379 172.22.0.3:6379 172.22.0.4:6379 \
10+
172.22.0.5:6379 172.22.0.6:6379 172.22.0.7:6379 \
11+
--cluster-replicas 1 && tail -f /dev/null'
12+
depends_on:
13+
- redis-1
14+
- redis-2
15+
- redis-3
16+
- redis-4
17+
- redis-5
18+
- redis-6
19+
networks:
20+
redis-net:
21+
ipv4_address: 172.22.0.10
22+
23+
redis-1:
24+
container_name: "redis-1"
25+
image: redis:6.0-alpine
26+
ports:
27+
- 7001:6379
28+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
29+
depends_on:
30+
- redis-2
31+
- redis-3
32+
- redis-4
33+
- redis-5
34+
- redis-6
35+
networks:
36+
redis-net:
37+
ipv4_address: 172.22.0.2
38+
39+
redis-2:
40+
container_name: "redis-2"
41+
image: redis:6.0-alpine
42+
ports:
43+
- 7002:6379
44+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
45+
networks:
46+
redis-net:
47+
ipv4_address: 172.22.0.3
48+
49+
redis-3:
50+
container_name: "redis-3"
51+
image: redis:6.0-alpine
52+
ports:
53+
- 7003:6379
54+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
55+
networks:
56+
redis-net:
57+
ipv4_address: 172.22.0.4
58+
59+
redis-4:
60+
container_name: "redis-4"
61+
image: redis:6.0-alpine
62+
ports:
63+
- 7004:6379
64+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
65+
networks:
66+
redis-net:
67+
ipv4_address: 172.22.0.5
68+
69+
redis-5:
70+
container_name: "redis-5"
71+
image: redis:6.0-alpine
72+
ports:
73+
- 7005:6379
74+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
75+
networks:
76+
redis-net:
77+
ipv4_address: 172.22.0.6
78+
79+
redis-6:
80+
container_name: "redis-6"
81+
image: redis:6.0-alpine
82+
ports:
83+
- 7006:6379
84+
command: ["redis-server", "--cluster-enabled", "yes", "--cluster-config-file", "nodes.conf", "--cluster-node-timeout", "5000", "--appendonly", "yes"]
85+
86+
networks:
87+
redis-net:
88+
ipv4_address: 172.22.0.7
89+
90+
networks:
91+
redis-net:
92+
driver: bridge
93+
ipam:
94+
config:
95+
- subnet: 172.22.0.0/16

0 commit comments

Comments
 (0)