Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b89230e
feat: solution for step 1
loicmathieu Sep 17, 2019
64e86f9
feat(*): step 1
aoudiamoncef Oct 29, 2019
25a10f0
Merge pull request #11 from aoudiamoncef/step-1
loicmathieu May 24, 2020
b4b0bc5
fix: bad merge
loicmathieu May 24, 2020
117b2fd
feat: solution for step 2
loicmathieu Sep 18, 2019
5556829
feat: solution for step 2
loicmathieu Sep 18, 2019
03f25ad
feat: solution for step 1
loicmathieu Sep 17, 2019
4d99d30
feat: solution for step 2
loicmathieu Sep 18, 2019
cead24c
feat(*): step 2
aoudiamoncef Oct 29, 2019
cc7b402
Merge pull request #12 from aoudiamoncef/step-2
loicmathieu May 25, 2020
102df79
feat: solution for step 3
loicmathieu Sep 18, 2019
a74a35f
feat: solution for step 2
loicmathieu Sep 18, 2019
fd460bc
feat: solution for step 3
loicmathieu Sep 18, 2019
8c659e0
feat: solution for step 1
loicmathieu Sep 17, 2019
8c9229a
feat: solution for step 2
loicmathieu Sep 18, 2019
88567e7
feat: solution for step 3
loicmathieu Sep 18, 2019
3001597
feat(*): step 3
aoudiamoncef Oct 29, 2019
c5cc8cc
Merge pull request #13 from aoudiamoncef/step-3
loicmathieu May 25, 2020
3ca3873
feat: solution for step 2
loicmathieu Sep 18, 2019
e629447
feat: solution for step 3
loicmathieu Sep 18, 2019
9af6398
feat: solution for step 5
loicmathieu Sep 18, 2019
bbe43c8
feat: solution for step 1
loicmathieu Sep 17, 2019
a9afcc9
feat: solution for step 2
loicmathieu Sep 18, 2019
1f23dd3
feat: solution for step 3
loicmathieu Sep 18, 2019
24ff737
feat: solution for step 5
loicmathieu Sep 18, 2019
58f5c4b
feat(*): step 5
aoudiamoncef Oct 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ 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 `log.info("Hello {}", greeting)` using [SLFJ](https://www.slf4j.org/).
- 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).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment, please don't do this if it previously works as the LOG usage is froma different step

- 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
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>0.28.1</quarkus.version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the quarkus version in master and rebase all branches later. Can you revert this change ?

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down
22 changes: 17 additions & 5 deletions bookmark-service/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.26.1</quarkus.version>
<quarkus.version>0.28.1</quarkus.version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the quarkus version in master and rebase all branches later. Can you revert this change ?

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down Expand Up @@ -42,19 +42,22 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<!-- Step 5 dependencies -->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<!--/ Step 5 dependencies -->
<!-- Step 6 dependencies -->
Comment on lines +50 to +51
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-metrics</artifactId>
</dependency>
<!-- Step 5 dependencies -->
<!-- <dependency>-->
<!-- <groupId>io.quarkus</groupId>-->
<!-- <artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
</dependency>
<!--/ Step 5 dependencies -->
<!-- Step 6 dependencies -->
<!-- <dependency>-->
Expand All @@ -74,6 +77,15 @@
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<!--/ Step 6 dependencies -->


<!-- test dependencies-->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
Comment on lines +83 to +88
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.loicmathieu.bookmarkit;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Readiness;

@Readiness
public class AppHealthCheck implements HealthCheck {

@Override
public HealthCheckResponse call() {
return HealthCheckResponse.builder().name("bookmark").withData("is", "always").up().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package fr.loicmathieu.bookmarkit;

import io.quarkus.hibernate.orm.panache.PanacheEntity;

import javax.persistence.Entity;

@Entity
public class Bookmark {
public class Bookmark extends PanacheEntity {
public String title;
public String url;
public String description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
package fr.loicmathieu.bookmarkit;

import io.smallrye.reactive.messaging.annotations.Channel;
import io.smallrye.reactive.messaging.annotations.Emitter;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Timed;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.logging.Logger;

import javax.annotation.PostConstruct;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
Expand All @@ -12,23 +27,72 @@
@Consumes(MediaType.APPLICATION_JSON)
public class BookmarkResource {

private static final Logger LOGGER = Logger.getLogger(BookmarkResource.class);

@ConfigProperty(name = "greeting")
private String greeting;

@Channel("bookmarks")
private Emitter<Bookmark> emitter;

@PostConstruct
void init() {
LOGGER.infof("Hello %s", greeting);
}

@GET
@Operation(summary = "List all bookmarks")
@Counted(name = "listBookmarks.count")
@Timed(name = "listBookmarks.time")
public List<Bookmark> listBookmarks() {
throw new UnsupportedOperationException("not yet implemented");
return Bookmark.listAll();
}

public Bookmark getBookmark(Long id) {
throw new UnsupportedOperationException("not yet implemented");
@GET
@Path("{id}")
@Operation(summary = "Get a bookmark")
@Counted(name = "getBookmark.count")
@Timed(name = "getBookmark.time")
public Bookmark getBookmark(@PathParam("id") Long id) {
return Bookmark.findById(id);
}

@POST
@Transactional
@Operation(summary = "Create a bookmark")
@Counted(name = "createBookmark.count")
@Timed(name = "createBookmark.time")
public Response createBookmark(Bookmark bookmark) {
throw new UnsupportedOperationException("not yet implemented");
bookmark.persist();
this.emitter.send(bookmark);
return Response.status(Response.Status.CREATED).entity(bookmark).build();
}

public Response updateBookmark(Bookmark bookmark, Long id) {
throw new UnsupportedOperationException("not yet implemented");
@PUT
@Path("{id}")
@Transactional
@Operation(summary = "Update a bookmark")
@Counted(name = "updateBookmark.count")
@Timed(name = "updateBookmark.time")
public void updateBookmark(Bookmark bookmark, @PathParam("id") Long id) {
Bookmark entity = Bookmark.findById(id);
entity.description = bookmark.description;
entity.location = bookmark.location;
entity.title = bookmark.title;
entity.url = bookmark.url;
}

public Response deleteBookmark(Long id) {
throw new UnsupportedOperationException("not yet implemented");
@DELETE
@Path("{id}")
@Transactional
@Operation(summary = "Delete a bookmark")
@Counted(name = "deleteBookmark.count")
@Timed(name = "deleteBookmark.time")
public Response deleteBookmark(@PathParam("id") Long id) {
Bookmark bookmark = Bookmark.findById(id);
if (bookmark != null) {
bookmark.delete();
}
return Response.noContent().build();
}
}
10 changes: 10 additions & 0 deletions bookmark-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Configures the AMQP broker credentials.
amqp-username=quarkus
amqp-password=quarkus
# Configure the AMQP connector to write to the `bookmark` address
mp.messaging.outgoing.bookmarks.connector=smallrye-amqp
mp.messaging.outgoing.bookmarks.address=bookmarks
mp.messaging.outgoing.bookmarks.durable=true
# Datasource configuration
quarkus.datasource.url=jdbc:postgresql://localhost:5432/bookmarkit
quarkus.datasource.driver=org.postgresql.Driver
Expand All @@ -6,3 +13,6 @@ quarkus.datasource.password=quarkus
# drop and create the database at startup (use `update` to only update the schema)
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.sql-load-script=import.sql

greeting=World
%dev.greeting=Dev
2 changes: 1 addition & 1 deletion geoip-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>0.26.1</quarkus.version>
<quarkus.version>0.28.1</quarkus.version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change the quarkus version later from master ...

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down