diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2e896c1..155b53c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,12 +6,14 @@ on:
- "main"
paths:
- "customer-api-provider/**"
+ - "customer-api-consumer/**"
- ".github/**"
pull_request:
branches:
- "main"
paths:
- "customer-api-provider/**"
+ - "customer-api-consumer/**"
- ".github/**"
jobs:
@@ -30,3 +32,6 @@ jobs:
- name: Build API Provider with Maven
working-directory: customer-api-provider
run: mvn -B package --file pom.xml
+ - name: Build API Consumer with Maven
+ working-directory: customer-api-consumer
+ run: mvn -B package --file pom.xml
diff --git a/customer-api-consumer/.gitignore b/customer-api-consumer/.gitignore
new file mode 100644
index 0000000..91a800a
--- /dev/null
+++ b/customer-api-consumer/.gitignore
@@ -0,0 +1,45 @@
+#Maven
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+release.properties
+.flattened-pom.xml
+
+# Eclipse
+.project
+.classpath
+.settings/
+bin/
+
+# IntelliJ
+.idea
+*.ipr
+*.iml
+*.iws
+
+# NetBeans
+nb-configuration.xml
+
+# Visual Studio Code
+.vscode
+.factorypath
+
+# OSX
+.DS_Store
+
+# Vim
+*.swp
+*.swo
+
+# patch
+*.orig
+*.rej
+
+# Local environment
+.env
+
+# Plugin directory
+/.quarkus/cli/plugins/
+# TLS Certificates
+.certs/
diff --git a/customer-api-consumer/pom.xml b/customer-api-consumer/pom.xml
new file mode 100644
index 0000000..3de9f4c
--- /dev/null
+++ b/customer-api-consumer/pom.xml
@@ -0,0 +1,162 @@
+
+
+ 4.0.0
+ de.schulung.quarkus
+ customer-api-consumer
+ 1.0.0-SNAPSHOT
+
+
+ 3.12.1
+ 17
+ UTF-8
+ UTF-8
+ quarkus-bom
+ io.quarkus.platform
+ 3.13.3
+ true
+ 3.2.5
+ 1.18.32
+
+
+
+
+
+ io.quarkus.platform
+ quarkus-bom
+ ${quarkus.platform.version}
+ pom
+ import
+
+
+
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ io.quarkus
+ quarkus-arc
+
+
+ io.quarkus
+ quarkus-rest-jsonb
+
+
+ io.quarkus
+ quarkus-rest-client-jsonb
+
+
+ io.quarkus
+ quarkus-smallrye-health
+
+
+ io.quarkus
+ quarkus-cache
+
+
+ io.quarkus
+ quarkus-junit5
+ test
+
+
+ io.quarkus
+ quarkus-junit5-mockito
+ test
+
+
+
+
+
+
+
+ maven-compiler-plugin
+ ${compiler-plugin.version}
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+
+
+
+
+
+ ${quarkus.platform.group-id}
+ quarkus-maven-plugin
+ ${quarkus.platform.version}
+ true
+
+
+
+ build
+ generate-code
+ generate-code-tests
+
+
+
+
+
+ maven-compiler-plugin
+
+
+ -parameters
+
+
+
+
+ maven-surefire-plugin
+ ${surefire-plugin.version}
+
+
+ org.jboss.logmanager.LogManager
+ ${maven.home}
+
+
+
+
+ maven-failsafe-plugin
+ ${surefire-plugin.version}
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}-runner
+
+ org.jboss.logmanager.LogManager
+ ${maven.home}
+
+
+
+
+
+
+
+
+ native
+
+
+ native
+
+
+
+ false
+ true
+
+
+
+
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerConsumerApplication.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerConsumerApplication.java
new file mode 100644
index 0000000..edd116b
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerConsumerApplication.java
@@ -0,0 +1,13 @@
+package de.schulung.sample.consumer;
+
+import io.quarkus.runtime.Quarkus;
+import io.quarkus.runtime.annotations.QuarkusMain;
+
+@QuarkusMain
+public class CustomerConsumerApplication {
+
+ public static void main(String[] args) {
+ Quarkus.run(args);
+ }
+
+}
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerService.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerService.java
new file mode 100644
index 0000000..cb6db42
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomerService.java
@@ -0,0 +1,29 @@
+package de.schulung.sample.consumer;
+
+import de.schulung.sample.consumer.client.CustomerApi;
+import de.schulung.sample.consumer.client.CustomerDto;
+import io.quarkus.cache.CacheInvalidateAll;
+import io.quarkus.cache.CacheResult;
+import io.smallrye.mutiny.Uni;
+import jakarta.enterprise.context.ApplicationScoped;
+import lombok.RequiredArgsConstructor;
+
+import java.util.Collection;
+
+@ApplicationScoped
+@RequiredArgsConstructor
+public class CustomerService {
+
+ private final CustomerApi customerApi;
+
+ // https://quarkus.io/guides/cache
+
+ @CacheResult(cacheName = "customers-api-cache")
+ public Uni> getAllCustomers() { // quick'n'dirty without mapping!
+ return customerApi.getAllCustomers();
+ }
+
+ @CacheInvalidateAll(cacheName = "customers-api-cache")
+ public void reset(){}
+
+}
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomersResource.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomersResource.java
new file mode 100644
index 0000000..d22602b
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/CustomersResource.java
@@ -0,0 +1,39 @@
+package de.schulung.sample.consumer;
+
+import de.schulung.sample.consumer.client.CustomerDto;
+import io.smallrye.mutiny.Uni;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import lombok.RequiredArgsConstructor;
+
+import java.util.stream.Collectors;
+
+@RequiredArgsConstructor
+@Path("/customers")
+public class CustomersResource {
+
+ private final CustomerService service;
+
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Uni getCustomerNames() {
+ return this.service
+ .getAllCustomers()
+ .map(list -> list
+ .stream()
+ .map(CustomerDto::getName)
+ .collect(Collectors.joining("\n"))
+ );
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ @Path("/reset")
+ public String reset() {
+ this.service.reset();
+ return "Done.";
+ }
+
+}
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApi.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApi.java
new file mode 100644
index 0000000..a4bfda0
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApi.java
@@ -0,0 +1,22 @@
+package de.schulung.sample.consumer.client;
+
+import io.smallrye.mutiny.Uni;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
+
+import java.util.Collection;
+
+@RegisterRestClient(configKey = "customer-api")
+@Path("/customers")
+public interface CustomerApi {
+
+ // https://quarkus.io/guides/rest-client
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ Uni> getAllCustomers();
+
+}
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApiProvider.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApiProvider.java
new file mode 100644
index 0000000..61b1efe
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerApiProvider.java
@@ -0,0 +1,19 @@
+package de.schulung.sample.consumer.client;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.inject.Default;
+import jakarta.enterprise.inject.Produces;
+import lombok.Getter;
+import org.eclipse.microprofile.rest.client.inject.RestClient;
+
+@ApplicationScoped
+public class CustomerApiProvider {
+
+ @RestClient
+ @Getter(onMethod_ = {
+ @Produces,
+ @Default
+ })
+ CustomerApi customerApi;
+
+}
diff --git a/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerDto.java b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerDto.java
new file mode 100644
index 0000000..fad8199
--- /dev/null
+++ b/customer-api-consumer/src/main/java/de/schulung/sample/consumer/client/CustomerDto.java
@@ -0,0 +1,24 @@
+package de.schulung.sample.consumer.client;
+
+import jakarta.json.bind.annotation.JsonbProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.time.LocalDate;
+import java.util.UUID;
+
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+public class CustomerDto {
+
+ private UUID uuid;
+ private String name;
+ @JsonbProperty("birthdate")
+ private LocalDate birthDate;
+ private String state;
+
+}
diff --git a/customer-api-consumer/src/main/resources/application.properties b/customer-api-consumer/src/main/resources/application.properties
new file mode 100644
index 0000000..4a64edc
--- /dev/null
+++ b/customer-api-consumer/src/main/resources/application.properties
@@ -0,0 +1,10 @@
+%dev.quarkus.http.port=8081
+%dev.quarkus.rest-client."customer-api".url=http://localhost:8080/api/v1
+quarkus.rest-client."customer-api".connect-timeout=2000
+%dev.quarkus.rest-client."customer-api".read-timeout=2000
+quarkus.cache.caffeine."customers-api-cache".metrics-enabled=true
+quarkus.cache.caffeine."customers-api-cache".expire-after-write=60S
+quarkus.management.port=9091
+quarkus.management.enabled=true
+%dev.quarkus.management.host=localhost
+