Skip to content

Commit a6eef4f

Browse files
authored
Migration to Quarkus 2 (#3)
1 parent 90bbd29 commit a6eef4f

20 files changed

+180
-67
lines changed

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
22
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
This repo is a fork of the original one based in [Spring Boot](https://github.com/rmarting/kafka-clients-sb-sample)
66
but refactored to be a full-compliant [Quarkus](https://quarkus.io/) application. This repo is described in
7-
[Integrating Quarkus and Apicurio Service Registry](https://blog.jromanmartin.io/2020/12/18/integrating-quarkus-and-apicurio-service-registry.html) blog post.
7+
[Integrating Quarkus and Apicurio Service Registry](https://blog.jromanmartin.io/2020/12/18/integrating-quarkus-and-apicurio-service-registry.html)
8+
blog post.
89

910
The following components were refactored from Spring Boot to Quarkus Extensions:
1011

@@ -20,7 +21,8 @@ The following components were refactored from Spring Boot to Quarkus Extensions:
2021
This new version is really fast (less than 2 seconds) ... like a :rocket:
2122

2223
```text
23-
2021-06-24 07:56:54,886 INFO [io.quarkus] (main) kafka-clients-quarkus-sample 2.0.0-SNAPSHOT on JVM (powered by Quarkus 1.13.7.Final) started in 1.756s. Listening on: http://0.0.0.0:8181
24+
Jun 30, 2021 9:57:02 PM io.quarkus.bootstrap.runner.Timing printStartupTime
25+
INFO: kafka-clients-quarkus-sample 2.0.0-SNAPSHOT on JVM (powered by Quarkus 2.0.0.Final) started in 1.755s. Listening on: http://0.0.0.0:8181
2426
```
2527

2628
## :rocket: :sparkles: :rotating_light: QUARKUS EDITION :rotating_light: :sparkles: :rocket:
@@ -298,7 +300,7 @@ To register the schemas in Service Registry running in OpenShift:
298300
❯ ./mvnw clean generate-sources -Papicurio
299301
```
300302

301-
The next screenshot shows the schemas registed in the Web Console:
303+
The next screenshot shows the schemas registered in the Web Console:
302304

303305
![Artifacts registered in Apicurio Registry](./img/apicurio-registry-artifacts.png)
304306

@@ -370,21 +372,29 @@ Or you can deploy into Kubernetes or OpenShift platform using [Eclipse JKube](ht
370372
To deploy the application using the Kubernetes Maven Plug-In:
371373

372374
```shell
373-
❯ ./mvnw package k8s:resource k8s:build k8s:push k8s:apply -Pkubernetes -Djkube.build.strategy=jib
375+
eval $(minikube docker-env)
376+
❯ kubectl create -f src/main/k8s/role.yml
377+
❯ ./mvnw package k8s:resource k8s:build k8s:apply -Pkubernetes
378+
```
379+
380+
If you want to deploy the native version of this project:
381+
382+
```shell
383+
eval $(minikube docker-env)
384+
❯ kubectl create -f src/main/k8s/role.yml
385+
❯ ./mvnw package k8s:resource k8s:build k8s:apply -Pnative,kubernetes
374386
```
375387

376388
To deploy the application using the OpenShift Maven Plug-In (only valid for OpenShift Platform):
377389

378390
```shell script
379-
❯ ./mvnw package oc:resource oc:build oc:apply -Popenshift,native -Dquarkus.native.container-build=true
391+
❯ ./mvnw package oc:resource oc:build oc:apply -Popenshift
380392
```
381393

382-
To deploy the application in Minikube:
394+
If you want to deploy the native version of this project:
383395

384396
```shell script
385-
eval $(minikube docker-env)
386-
❯ kubectl create -f src/main/k8s/role.yml
387-
❯ ./mvnw package k8s:resource k8s:build k8s:apply -Pkubernetes
397+
❯ ./mvnw package oc:resource oc:build oc:apply -Pnative,openshift -Dquarkus.native.container-build=true
388398
```
389399

390400
# REST API
@@ -503,8 +513,8 @@ With Minikube:
503513
}
504514
```
505515

506-
That is! You have been deployed a full stack of components to produce and consume checked and valid messages using
507-
a schema declared. Congratulations!.
516+
That's all folks! You have been deployed a full stack of components to produce and consume checked and
517+
valid messages using a schema declared. Congratulations!.
508518

509519
## Main References
510520

@@ -517,4 +527,5 @@ a schema declared. Congratulations!.
517527
* [Quarkus - Using OpenAPI and Swagger UI](https://quarkus.io/guides/openapi-swaggerui)
518528
* [Quarkus - Contexts and Dependency Injection](https://quarkus.io/guides/cdi-reference)
519529
* [Quarkus - Using Apache Kafka with Reactive Messaging](https://quarkus.io/guides/kafka)
530+
* [Quarkus - How to Use Kafka, Schema Registry and Avro with Quarkus](https://quarkus.io/blog/kafka-avro/)
520531
* [Quarkus - Configuring your application](https://quarkus.io/guides/config)

mvnw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# "License"); you may not use this file except in compliance
99
# with the License. You may obtain a copy of the License at
1010
#
11-
# http://www.apache.org/licenses/LICENSE-2.0
11+
# https://www.apache.org/licenses/LICENSE-2.0
1212
#
1313
# Unless required by applicable law or agreed to in writing,
1414
# software distributed under the License is distributed on an

mvnw.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@REM "License"); you may not use this file except in compliance
88
@REM with the License. You may obtain a copy of the License at
99
@REM
10-
@REM http://www.apache.org/licenses/LICENSE-2.0
10+
@REM https://www.apache.org/licenses/LICENSE-2.0
1111
@REM
1212
@REM Unless required by applicable law or agreed to in writing,
1313
@REM software distributed under the License is distributed on an

pom.xml

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<jkube.generator.name>${project.artifactId}:${project.version}</jkube.generator.name>
4040
<jkube.generator.quarkus.webPort>8181</jkube.generator.quarkus.webPort>
4141
<!-- Quarkus -->
42-
<quarkus.platform.version>1.13.7.Final</quarkus.platform.version>
42+
<quarkus.platform.version>2.0.1.Final</quarkus.platform.version>
4343
</properties>
4444

4545
<dependencies>
@@ -83,6 +83,12 @@
8383
<artifactId>quarkus-avro</artifactId>
8484
</dependency>
8585

86+
<!-- Apicurio Registry Avro Schemas Extension -->
87+
<dependency>
88+
<groupId>io.quarkus</groupId>
89+
<artifactId>quarkus-apicurio-registry-avro</artifactId>
90+
</dependency>
91+
8692
<!-- Apicurio Serializers/Deserializers -->
8793
<dependency>
8894
<groupId>io.apicurio</groupId>
@@ -91,7 +97,21 @@
9197
</dependency>
9298

9399
<!-- Test Dependencies -->
94-
<!-- TODO -->
100+
<dependency>
101+
<groupId>io.quarkus</groupId>
102+
<artifactId>quarkus-junit5</artifactId>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>io.rest-assured</groupId>
107+
<artifactId>rest-assured</artifactId>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>io.smallrye.reactive</groupId>
112+
<artifactId>smallrye-reactive-messaging-in-memory</artifactId>
113+
<scope>test</scope>
114+
</dependency>
95115
</dependencies>
96116

97117
<build>
@@ -112,13 +132,15 @@
112132
</plugin>
113133

114134
<plugin>
135+
<groupId>org.apache.maven.plugins</groupId>
115136
<artifactId>maven-compiler-plugin</artifactId>
116137
<version>${compiler-plugin.version}</version>
117138
<configuration>
118139
<parameters>${maven.compiler.parameters}</parameters>
119140
</configuration>
120141
</plugin>
121142
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
122144
<artifactId>maven-surefire-plugin</artifactId>
123145
<version>${surefire-plugin.version}</version>
124146
<configuration>
@@ -128,34 +150,13 @@
128150
</systemPropertyVariables>
129151
</configuration>
130152
</plugin>
131-
132-
<!-- Avro Maven Plug-In to generate classes from schemas (files *.avsc) -->
133153
<plugin>
134-
<groupId>org.apache.avro</groupId>
135-
<artifactId>avro-maven-plugin</artifactId>
136-
<version>${avro.version}</version>
137-
<executions>
138-
<execution>
139-
<!-- Generate Java Classes in generate-sources maven phase -->
140-
<phase>generate-sources</phase>
141-
<goals>
142-
<goal>schema</goal>
143-
</goals>
144-
<configuration>
145-
<!-- Source Folder with Avro Schemas -->
146-
<sourceDirectory>${project.basedir}/src/main/resources/schemas</sourceDirectory>
147-
<includes>
148-
<!-- Avro Schemas extension file pattern -->
149-
<include>**/*.avsc</include>
150-
</includes>
151-
<outputDirectory>${project.build.directory}/generated-sources/schemas</outputDirectory>
152-
<stringType>String</stringType>
153-
</configuration>
154-
</execution>
155-
</executions>
154+
<groupId>org.apache.maven.plugins</groupId>
155+
<artifactId>maven-surefire-report-plugin</artifactId>
156+
<version>${surefire-plugin.version}</version>
156157
</plugin>
157158

158-
<!-- Extending source resources to add generated classes by Avro -->
159+
<!-- Extending source resources to add generated classes by Quarkus Avro -->
159160
<plugin>
160161
<groupId>org.codehaus.mojo</groupId>
161162
<artifactId>build-helper-maven-plugin</artifactId>
@@ -171,7 +172,7 @@
171172
<configuration>
172173
<sources>
173174
<!-- Output folder defined in generate phase -->
174-
<source>${project.build.directory}/generated-sources/schemas</source>
175+
<source>${project.build.directory}/generated-sources/avsc</source>
175176
</sources>
176177
</configuration>
177178
</execution>
@@ -203,9 +204,10 @@
203204
<artifact>
204205
<groupId>default</groupId>
205206
<artifactId>messages</artifactId>
207+
<version>2.0</version>
206208
<type>AVRO</type>
207209
<file>
208-
${project.basedir}/src/main/resources/schemas/message.avsc
210+
${project.basedir}/src/main/avro/message.avsc
209211
</file>
210212
<ifExists>RETURN_OR_UPDATE</ifExists>
211213
<canonicalize>true</canonicalize>
@@ -215,9 +217,10 @@
215217
<artifact>
216218
<groupId>default</groupId>
217219
<artifactId>messages-value</artifactId>
220+
<version>2.0</version>
218221
<type>AVRO</type>
219222
<file>
220-
${project.basedir}/src/main/resources/schemas/message.avsc
223+
${project.basedir}/src/main/avro/message.avsc
221224
</file>
222225
<ifExists>RETURN_OR_UPDATE</ifExists>
223226
<canonicalize>true</canonicalize>
@@ -227,9 +230,10 @@
227230
<artifact>
228231
<groupId>io.jromanmartin.kafka.schema.avro</groupId>
229232
<artifactId>Message</artifactId>
233+
<version>2.0</version>
230234
<type>AVRO</type>
231235
<file>
232-
${project.basedir}/src/main/resources/schemas/message.avsc
236+
${project.basedir}/src/main/avro/message.avsc
233237
</file>
234238
<ifExists>RETURN_OR_UPDATE</ifExists>
235239
<canonicalize>true</canonicalize>
@@ -282,6 +286,7 @@
282286
<build>
283287
<plugins>
284288
<plugin>
289+
<groupId>org.apache.maven.plugins</groupId>
285290
<artifactId>maven-failsafe-plugin</artifactId>
286291
<version>${surefire-plugin.version}</version>
287292
<executions>
File renamed without changes.

src/main/docker/Dockerfile.jvm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Then, build the image with:
99
#
10-
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/kafka-clients-quarkus-sample .
10+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/kafka-clients-quarkus-sample-jvm .
1111
#
1212
# Then run the container using:
1313
#
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/kafka-clients-quarkus-sample-jvm
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
2525

2626
ARG JAVA_PACKAGE=java-11-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8
@@ -52,3 +52,4 @@ EXPOSE 8080
5252
USER 1001
5353

5454
ENTRYPOINT [ "/deployments/run-java.sh" ]
55+

src/main/docker/Dockerfile.legacy-jar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/kafka-clients-quarkus-sample-legacy-jar
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
2525

2626
ARG JAVA_PACKAGE=java-11-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8

src/main/docker/Dockerfile.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# docker run -i --rm -p 8080:8080 quarkus/kafka-clients-quarkus-sample
1515
#
1616
###
17-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
1818
WORKDIR /work/
1919
RUN chown 1001 /work \
2020
&& chmod "g+rwX" /work \

0 commit comments

Comments
 (0)