Skip to content

Commit

Permalink
feat(*): step 6
Browse files Browse the repository at this point in the history
feat: small enhancements


feat: solution for step 3


feat: solution for step 5


feat: solution for step 6


refactor(*): Update Postman collection


feat(*): step 6
  • Loading branch information
aoudiamoncef committed Dec 2, 2019
1 parent 086daf4 commit 22002ec
Show file tree
Hide file tree
Showing 40 changed files with 514 additions and 956 deletions.
52 changes: 29 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt
# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# Mobile Tools for Java (J2ME)
.mtj.tmp/
# NetBeans
nb-configuration.xml

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# Visual Studio Code
.vscode

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# OSX
.DS_Store

.idea/
# Vim
*.swp
*.swo

*.iml
# patch
*.orig
*.rej

bookmark-service/target
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
59 changes: 39 additions & 20 deletions Bookmarkit.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/bookmarks",
"host": [
Expand Down Expand Up @@ -60,10 +56,6 @@
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/bookmarks/1",
"host": [
Expand Down Expand Up @@ -141,10 +133,6 @@
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/openapi",
"host": [
Expand All @@ -169,10 +157,6 @@
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:8080/metrics/application",
"protocol": "http",
Expand All @@ -193,10 +177,6 @@
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/health",
"host": [
Expand All @@ -209,6 +189,45 @@
}
},
"response": []
},
{
"name": "GET /geoip",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8093/geoip",
"protocol": "http",
"host": [
"localhost"
],
"port": "8093",
"path": [
"geoip"
]
}
},
"response": []
},
{
"name": "GET /geoip/{ip}",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8093/geoip/8.8.8.8",
"protocol": "http",
"host": [
"localhost"
],
"port": "8093",
"path": [
"geoip",
"8.8.8.8"
]
}
},
"response": []
}
]
}
5 changes: 3 additions & 2 deletions GENERATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
mvn io.quarkus:quarkus-maven-plugin:0.22.0:create \
mvn io.quarkus:quarkus-maven-plugin:0.26.1:create \
-DprojectGroupId=fr.loicmathieu.bookmarkit \
-DprojectArtifactId=bookmark-service \
-DclassName="fr.loicmathieu.bookmarkit.BookmarkResource" \
-Dpath="/bookmarks" \
-Dextensions="resteasy-jsonb,openapi,metrics,health,rest-client,hibernate-orm-panache,jdbc-postgresql,fault-tolerance,amqp"

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

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There is a Postman collection that can help to test your application during you

## Step 1 - Quarkus basics

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

Steps:

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

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`.

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

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.

Expand All @@ -62,9 +62,9 @@ Steps:

- Add a configuration property inside you `application.properties` file: `greeting=World`
- Modify `BookmarkResource` to read this configuration property and log it at startup:
- Use `@@ConfigProperty` to inject the property inside a `greeting` variable.
- Create a `@PostConstruct` method that log it via `System.out.println("Hello " + greeting)`.
- Test using `mvn quarkus:dev` you should see `Hello World` in the console when you hit the endpoint.
- Use `@ConfigProperty` to inject the property inside a `greeting` variable.
- 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).
- Test using `mvn quarkus:dev` you should see `Hello World` in the console.
- Add a new line to `application.properties` file: `%dev.greeting=Dev` this is an override of the same property for the dev profile.
- Test using `mvn quarkus:dev` you should see `Hello Dev` in the console.

Expand Down
37 changes: 37 additions & 0 deletions bookmark-message-consumer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/ObjectStore/

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
2 changes: 1 addition & 1 deletion bookmark-message-consumer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<quarkus.version>0.22.0</quarkus.version>
<quarkus.version>1.0.1.Final</quarkus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package fr.loicmathieu.bookmarkit;

import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.jboss.logging.Logger;

import javax.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class BookmarkConsumer {

private static final Logger LOG = Logger.getLogger(BookmarkConsumer.class);

@Incoming("bookmarks")
public void process(String bookmark) {
System.out.println("Indexing a bookmark: " +bookmark );
LOG.infof("Indexing a bookmark: %s", bookmark);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

37 changes: 37 additions & 0 deletions bookmark-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/ObjectStore/

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
Loading

0 comments on commit 22002ec

Please sign in to comment.