Skip to content

Commit 2102886

Browse files
committed
feat: initial project
Signed-off-by: Otavio Santana <[email protected]>
1 parent 0491632 commit 2102886

File tree

12 files changed

+900
-26
lines changed

12 files changed

+900
-26
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!target/*-runner
3+
!target/*-runner.jar
4+
!target/lib/*
5+
!target/quarkus-app/*

.gitignore

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
21-
22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
24-
replay_pid*
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
.flattened-pom.xml
8+
9+
# Eclipse
10+
.project
11+
.classpath
12+
.settings/
13+
bin/
14+
15+
# IntelliJ
16+
.idea
17+
*.ipr
18+
*.iml
19+
*.iws
20+
21+
# NetBeans
22+
nb-configuration.xml
23+
24+
# Visual Studio Code
25+
.vscode
26+
.factorypath
27+
28+
# OSX
29+
.DS_Store
30+
31+
# Vim
32+
*.swp
33+
*.swo
34+
35+
# patch
36+
*.orig
37+
*.rej
38+
39+
# Local environment
40+
.env
41+
42+
# Plugin directory
43+
/.quarkus/cli/plugins/

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,58 @@
1-
# mongodb-virtual-threads
2-
Code Sample using MongoDB with Java 21 and Virtual Threads
1+
# quarkus-jnosql-mongodb
2+
3+
This project intents to provide a code sample about how to integrate Quarkus with JNoSQL.
4+
5+
This project uses Quarkus, the Supersonic Subatomic Java Framework.
6+
7+
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
8+
9+
## Running the application in dev mode
10+
11+
You can run your application in dev mode that enables live coding using:
12+
```shell script
13+
mvn compile quarkus:dev
14+
```
15+
16+
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
17+
18+
## Packaging and running the application
19+
20+
The application can be packaged using:
21+
```shell script
22+
mvn package
23+
```
24+
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
25+
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
26+
27+
The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
28+
29+
If you want to build an _über-jar_, execute the following command:
30+
```shell script
31+
mvn package -Dquarkus.package.type=uber-jar
32+
```
33+
34+
The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
35+
36+
## Creating a native executable
37+
38+
You can create a native executable using:
39+
```shell script
40+
mvn package -Pnative
41+
```
42+
43+
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
44+
```shell script
45+
mvn package -Pnative -Dquarkus.native.container-build=true
46+
```
47+
48+
You can then execute your native executable with: `./target/code-with-quarkus-1.0.0-SNAPSHOT-runner`
49+
50+
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
51+
52+
## Provided Code
53+
54+
### RESTEasy Reactive
55+
56+
Easily start your Reactive RESTful Web Services
57+
58+
[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources)

pom.xml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>org.br.soujava</groupId>
7+
<artifactId>mongodb-virtual-thread</artifactId>
8+
<version>1.0.1</version>
9+
<properties>
10+
<compiler-plugin.version>3.11.0</compiler-plugin.version>
11+
<maven.compiler.release>17</maven.compiler.release>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
15+
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
16+
<quarkus.platform.version>3.18.3</quarkus.platform.version>
17+
<assertj.version>3.24.2</assertj.version>
18+
<skipITs>true</skipITs>
19+
<surefire-plugin.version>3.0.0</surefire-plugin.version>
20+
</properties>
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>${quarkus.platform.group-id}</groupId>
25+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
26+
<version>${quarkus.platform.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.quarkus</groupId>
35+
<artifactId>quarkus-arc</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.quarkus</groupId>
39+
<artifactId>quarkus-rest</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.quarkus</groupId>
43+
<artifactId>quarkus-smallrye-openapi</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.quarkiverse.jnosql</groupId>
47+
<artifactId>quarkus-jnosql-document-mongodb</artifactId>
48+
<version>3.3.2</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>io.quarkus</groupId>
52+
<artifactId>quarkus-junit5</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>io.rest-assured</groupId>
57+
<artifactId>rest-assured</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>net.datafaker</groupId>
62+
<artifactId>datafaker</artifactId>
63+
<version>2.0.2</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.assertj</groupId>
67+
<artifactId>assertj-core</artifactId>
68+
<version>${assertj.version}</version>
69+
<scope>test</scope>
70+
</dependency>
71+
</dependencies>
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>${quarkus.platform.group-id}</groupId>
76+
<artifactId>quarkus-maven-plugin</artifactId>
77+
<version>${quarkus.platform.version}</version>
78+
<extensions>true</extensions>
79+
<executions>
80+
<execution>
81+
<goals>
82+
<goal>build</goal>
83+
<goal>generate-code</goal>
84+
<goal>generate-code-tests</goal>
85+
</goals>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
<plugin>
90+
<artifactId>maven-compiler-plugin</artifactId>
91+
<version>${compiler-plugin.version}</version>
92+
<configuration>
93+
<compilerArgs>
94+
<arg>-parameters</arg>
95+
</compilerArgs>
96+
</configuration>
97+
</plugin>
98+
<plugin>
99+
<artifactId>maven-surefire-plugin</artifactId>
100+
<version>${surefire-plugin.version}</version>
101+
<configuration>
102+
<systemPropertyVariables>
103+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
104+
<maven.home>${maven.home}</maven.home>
105+
</systemPropertyVariables>
106+
</configuration>
107+
</plugin>
108+
<plugin>
109+
<artifactId>maven-failsafe-plugin</artifactId>
110+
<version>${surefire-plugin.version}</version>
111+
<executions>
112+
<execution>
113+
<goals>
114+
<goal>integration-test</goal>
115+
<goal>verify</goal>
116+
</goals>
117+
<configuration>
118+
<systemPropertyVariables>
119+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
120+
</native.image.path>
121+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
122+
<maven.home>${maven.home}</maven.home>
123+
</systemPropertyVariables>
124+
</configuration>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
</plugins>
129+
</build>
130+
<profiles>
131+
<profile>
132+
<id>native</id>
133+
<activation>
134+
<property>
135+
<name>native</name>
136+
</property>
137+
</activation>
138+
<properties>
139+
<skipITs>false</skipITs>
140+
<quarkus.package.type>native</quarkus.package.type>
141+
</properties>
142+
</profile>
143+
</profiles>
144+
145+
<repositories>
146+
<repository>
147+
<id>jakarta.sonatype.org-snapshot</id>
148+
<url>https://jakarta.oss.sonatype.org/content/repositories/snapshots/</url>
149+
<releases>
150+
<enabled>false</enabled>
151+
</releases>
152+
<snapshots>
153+
<enabled>true</enabled>
154+
</snapshots>
155+
</repository>
156+
<repository>
157+
<id>oss.sonatype.org-snapshot</id>
158+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
159+
<releases>
160+
<enabled>false</enabled>
161+
</releases>
162+
<snapshots>
163+
<enabled>true</enabled>
164+
</snapshots>
165+
</repository>
166+
</repositories>
167+
</project>

src/main/docker/Dockerfile.jvm

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/code-with-quarkus-jvm .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
15+
#
16+
# If you want to include the debug port into your docker image
17+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19+
# when running the container
20+
#
21+
# Then run the container using :
22+
#
23+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
24+
#
25+
# This image uses the `run-java.sh` script to run the application.
26+
# This scripts computes the command line to execute your Java application, and
27+
# includes memory/GC tuning.
28+
# You can configure the behavior using the following environment properties:
29+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31+
# in JAVA_OPTS (example: "-Dsome.property=foo")
32+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33+
# used to calculate a default maximal heap memory based on a containers restriction.
34+
# If used in a container without any memory constraints for the container then this
35+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36+
# of the container available memory as set here. The default is `50` which means 50%
37+
# of the available memory is used as an upper boundary. You can skip this mechanism by
38+
# setting this value to `0` in which case no `-Xmx` option is added.
39+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40+
# is used to calculate a default initial heap memory based on the maximum heap memory.
41+
# If used in a container without any memory constraints for the container then this
42+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44+
# is used as the initial heap size. You can skip this mechanism by setting this value
45+
# to `0` in which case no `-Xms` option is added (example: "25")
46+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47+
# This is used to calculate the maximum value of the initial heap memory. If used in
48+
# a container without any memory constraints for the container then this option has
49+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
50+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
51+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53+
# when things are happening. This option, if set to true, will set
54+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56+
# true").
57+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62+
# (example: "20")
63+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64+
# (example: "40")
65+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66+
# (example: "4")
67+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68+
# previous GC times. (example: "90")
69+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72+
# contain the necessary JRE command-line options to specify the required GC, which
73+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74+
# - HTTPS_PROXY: The location of the https proxy. (example: "[email protected]:8080")
75+
# - HTTP_PROXY: The location of the http proxy. (example: "[email protected]:8080")
76+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77+
# accessed directly. (example: "foo.example.com,bar.example.com")
78+
#
79+
###
80+
FROM registry.access.redhat.com/ubi8/openjdk-17:1.15
81+
82+
ENV LANGUAGE='en_US:en'
83+
84+
85+
# We make four distinct layers so if there are application changes the library layers can be re-used
86+
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
87+
COPY --chown=185 target/quarkus-app/*.jar /deployments/
88+
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
89+
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
90+
91+
EXPOSE 8080
92+
USER 185
93+
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
94+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
95+

0 commit comments

Comments
 (0)