Skip to content

Commit 5ed4868

Browse files
committed
feat(*): step 6
feat: small enhancements feat: solution for step 3 feat: solution for step 5 feat: solution for step 6 refactor(*): Update Postman collection
1 parent 086daf4 commit 5ed4868

File tree

36 files changed

+510
-921
lines changed

36 files changed

+510
-921
lines changed

.gitignore

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
1+
# Eclipse
2+
.project
3+
.classpath
4+
.settings/
5+
bin/
6+
7+
# IntelliJ
8+
.idea
9+
*.ipr
10+
*.iml
11+
*.iws
912

10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
13+
# NetBeans
14+
nb-configuration.xml
1215

13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
16+
# Visual Studio Code
17+
.vscode
2118

22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
19+
# OSX
20+
.DS_Store
2421

25-
.idea/
22+
# Vim
23+
*.swp
24+
*.swo
2625

27-
*.iml
26+
# patch
27+
*.orig
28+
*.rej
2829

29-
bookmark-service/target
30+
# Maven
31+
target/
32+
pom.xml.tag
33+
pom.xml.releaseBackup
34+
pom.xml.versionsBackup
35+
release.properties

Bookmarkit.postman_collection.json

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
"request": {
1111
"method": "GET",
1212
"header": [],
13-
"body": {
14-
"mode": "raw",
15-
"raw": ""
16-
},
1713
"url": {
1814
"raw": "localhost:8080/bookmarks",
1915
"host": [
@@ -60,10 +56,6 @@
6056
"request": {
6157
"method": "GET",
6258
"header": [],
63-
"body": {
64-
"mode": "raw",
65-
"raw": ""
66-
},
6759
"url": {
6860
"raw": "localhost:8080/bookmarks/1",
6961
"host": [
@@ -141,10 +133,6 @@
141133
"type": "text"
142134
}
143135
],
144-
"body": {
145-
"mode": "raw",
146-
"raw": ""
147-
},
148136
"url": {
149137
"raw": "localhost:8080/openapi",
150138
"host": [
@@ -169,10 +157,6 @@
169157
"type": "text"
170158
}
171159
],
172-
"body": {
173-
"mode": "raw",
174-
"raw": ""
175-
},
176160
"url": {
177161
"raw": "http://localhost:8080/metrics/application",
178162
"protocol": "http",
@@ -193,10 +177,6 @@
193177
"request": {
194178
"method": "GET",
195179
"header": [],
196-
"body": {
197-
"mode": "raw",
198-
"raw": ""
199-
},
200180
"url": {
201181
"raw": "localhost:8080/health",
202182
"host": [
@@ -209,6 +189,45 @@
209189
}
210190
},
211191
"response": []
192+
},
193+
{
194+
"name": "GET /geoip",
195+
"request": {
196+
"method": "GET",
197+
"header": [],
198+
"url": {
199+
"raw": "http://localhost:8093/geoip",
200+
"protocol": "http",
201+
"host": [
202+
"localhost"
203+
],
204+
"port": "8093",
205+
"path": [
206+
"geoip"
207+
]
208+
}
209+
},
210+
"response": []
211+
},
212+
{
213+
"name": "GET /geoip/{ip}",
214+
"request": {
215+
"method": "GET",
216+
"header": [],
217+
"url": {
218+
"raw": "http://localhost:8093/geoip/8.8.8.8",
219+
"protocol": "http",
220+
"host": [
221+
"localhost"
222+
],
223+
"port": "8093",
224+
"path": [
225+
"geoip",
226+
"8.8.8.8"
227+
]
228+
}
229+
},
230+
"response": []
212231
}
213232
]
214233
}

GENERATE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
mvn io.quarkus:quarkus-maven-plugin:0.22.0:create \
1+
mvn io.quarkus:quarkus-maven-plugin:0.26.1:create \
22
-DprojectGroupId=fr.loicmathieu.bookmarkit \
33
-DprojectArtifactId=bookmark-service \
44
-DclassName="fr.loicmathieu.bookmarkit.BookmarkResource" \
55
-Dpath="/bookmarks" \
66
-Dextensions="resteasy-jsonb,openapi,metrics,health,rest-client,hibernate-orm-panache,jdbc-postgresql,fault-tolerance,amqp"
77

8-
mvn io.quarkus:quarkus-maven-plugin:0.22.0:create \
8+
mvn io.quarkus:quarkus-maven-plugin:0.26.1:create \
99
-DprojectGroupId=fr.loicmathieu.bookmarkit \
1010
-DprojectArtifactId=bookmark-message-consumer \
1111
-DclassName="fr.loicmathieu.bookmarkit.BookmarkConsumer" \
1212
-Dpath="/bookmarks" \
1313
-Dextensions="metrics,health,amqp"
14+

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ There is a Postman collection that can help to test your application during you
1313

1414
## Step 1 - Quarkus basics
1515

16-
Goal: implements a bookmark service that pass the test from `fr.loicmathieu.bookmarkit.BookmarkStep1Test`.
16+
Goal: implements a bookmark service that pass the test from `fr.loicmathieu.bookmarkit.BookmarkResourceTest`.
1717

1818
Steps:
1919

@@ -22,7 +22,7 @@ Steps:
2222
You must implement the service as a JAX-RS resource ([WRITING JSON REST SERVICES](https://quarkus.io/guides/rest-json-guide)).
2323
You must use Hibernate ORM with Panache to access the database ([SIMPLIFIED HIBERNATE ORM WITH PANACHE](https://quarkus.io/guides/hibernate-orm-panache-guide)).
2424
- Run the service with `mvn compile quarkus:dev` it has livereload !
25-
- Test that everything works with `mvn test -Dtest=BookmarkStep1Test `.
25+
- Test that everything works with `mvn test -Dtest=BookmarkResourceTest`.
2626

2727
NOTE: Hibernate is configured to drop and recreate the schema each time you restart your application. You can change this behaviour inside your `application.properties`.
2828

@@ -41,15 +41,15 @@ be careful that the name of the metric must be unique. You can access your metri
4141
- Create a custom check
4242
```
4343
@Readiness
44-
public class MyHealCheck implements HealthCheck {
44+
public class AppHealthCheck implements HealthCheck {
4545
4646
@Override
4747
public HealthCheckResponse call() {
48-
return HealthCheckResponse.builder().name("custom").withData("key", "value").up().build();
48+
return HealthCheckResponse.builder().name("bookmark").withData("is", "always").up().build();
4949
}
5050
}
5151
```
52-
- Test that everything works with `mvn test -Dtest=BookmarkStep2Test `.
52+
- Test that everything works with `mvn test -Dtest=BookmarkObservabilityTest`.
5353

5454
NOTE: OpenAPI and OpenMetrics works as soon as you integrate the extension inside your application as it provides default documentation and metrics. Health provides basic liveness and readyness checks, you can add your own if needed.
5555

@@ -62,9 +62,9 @@ Steps:
6262

6363
- Add a configuration property inside you `application.properties` file: `greeting=World`
6464
- Modify `BookmarkResource` to read this configuration property and log it at startup:
65-
- Use `@@ConfigProperty` to inject the property inside a `greeting` variable.
66-
- Create a `@PostConstruct` method that log it via `System.out.println("Hello " + greeting)`.
67-
- Test using `mvn quarkus:dev` you should see `Hello World` in the console when you hit the endpoint.
65+
- Use `@ConfigProperty` to inject the property inside a `greeting` variable.
66+
- Create a `@PostConstruct` method that log it via `LOGGER.infof("Hello %s", greeting)` using [Jboss logging](https://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html).
67+
- Test using `mvn quarkus:dev` you should see `Hello World` in the console.
6868
- Add a new line to `application.properties` file: `%dev.greeting=Dev` this is an override of the same property for the dev profile.
6969
- Test using `mvn quarkus:dev` you should see `Hello Dev` in the console.
7070

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/ObjectStore/
2+
3+
# Eclipse
4+
.project
5+
.classpath
6+
.settings/
7+
bin/
8+
9+
# IntelliJ
10+
.idea
11+
*.ipr
12+
*.iml
13+
*.iws
14+
15+
# NetBeans
16+
nb-configuration.xml
17+
18+
# Visual Studio Code
19+
.vscode
20+
21+
# OSX
22+
.DS_Store
23+
24+
# Vim
25+
*.swp
26+
*.swo
27+
28+
# patch
29+
*.orig
30+
*.rej
31+
32+
# Maven
33+
target/
34+
pom.xml.tag
35+
pom.xml.releaseBackup
36+
pom.xml.versionsBackup
37+
release.properties

bookmark-message-consumer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<surefire-plugin.version>2.22.0</surefire-plugin.version>
1010
<maven.compiler.target>1.8</maven.compiler.target>
1111
<maven.compiler.source>1.8</maven.compiler.source>
12-
<quarkus.version>0.22.0</quarkus.version>
12+
<quarkus.version>0.28.1</quarkus.version>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1515
</properties>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package fr.loicmathieu.bookmarkit;
22

33
import org.eclipse.microprofile.reactive.messaging.Incoming;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import javax.enterprise.context.ApplicationScoped;
68

79
@ApplicationScoped
810
public class BookmarkConsumer {
911

12+
private final Logger log = LoggerFactory.getLogger(BookmarkConsumer.class);
13+
1014
@Incoming("bookmarks")
1115
public void process(String bookmark) {
12-
System.out.println("Indexing a bookmark: " +bookmark );
16+
log.info("Indexing a bookmark: {}", bookmark);
1317
}
14-
}
18+
}

bookmark-message-consumer/src/test/java/fr/loicmathieu/bookmarkit/BookmarkConsumerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public void testHelloEndpoint() {
1818
.body(is("hello"));
1919
}
2020

21-
}
21+
}

bookmark-message-consumer/src/test/java/fr/loicmathieu/bookmarkit/NativeBookmarkConsumerIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
public class NativeBookmarkConsumerIT extends BookmarkConsumerTest {
77

88
// Execute the same tests but in native mode.
9-
}
9+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/data/git/bookmarkit/bookmark-message-consumer/src/main/java/fr/loicmathieu/bookmarkit/BookmarkConsumer.java
1+
/home/sparow199/Workspace/bookmarkit/bookmark-message-consumer/src/main/java/fr/loicmathieu/bookmarkit/BookmarkConsumer.java

0 commit comments

Comments
 (0)