mirror of
https://github.com/jlengrand/quarkus-workshop.git
synced 2026-03-10 08:41:21 +00:00
fixes
This commit is contained in:
@@ -250,7 +250,7 @@ String message;
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
When injecting a configured value, you can use `@Inject` @ConfigProperty` or just `@ConfigProperty`. The `@Inject` annotation is not necessary for members annotated with `@ConfigProperty`, a behavior which differs from https://microprofile.io/project/eclipse/microprofile-config[MicroProfile Config].
|
||||
When injecting a configured value, you can use `@Inject @ConfigProperty` or just `@ConfigProperty`. The `@Inject` annotation is not necessary for members annotated with `@ConfigProperty`, a behavior which differs from https://microprofile.io/project/eclipse/microprofile-config[MicroProfile Config].
|
||||
====
|
||||
|
||||
=== Add some external config
|
||||
|
||||
@@ -23,6 +23,7 @@ oc login https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT --insecure-sk
|
||||
----
|
||||
|
||||
Enter your username and password assigned to you:
|
||||
|
||||
* Username: **userNN**
|
||||
* Password: **passNN**
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
= Reactive Streams with Quarkus and Kafka
|
||||
:experimental:
|
||||
|
||||
In this exercise, you will use the Quarkus Kafka extension to build a streaming application using MicroProfile Reative Streams Messaging and https://kafka.apache.org[Apache Kafka], a distributed streaming platform. You will also use https://strimzi.io/[Strimzi], which provides an easy way to run an Apache Kafka cluster on Kubernetes using [Operators](https://operatorhub.io/what-is-an-operator).
|
||||
In this exercise, you will use the Quarkus Kafka extension to build a streaming application using MicroProfile Reative Streams Messaging and https://kafka.apache.org[Apache Kafka], a distributed streaming platform. You will also use https://strimzi.io/[Strimzi], which provides an easy way to run an Apache Kafka cluster on Kubernetes using https://operatorhub.io/what-is-an-operator[Operators].
|
||||
|
||||
== What is Apache Kafka?
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ We'll start by creating a new asynchronous endpoint. Open the `PersonResource` c
|
||||
----
|
||||
@Inject EventBus bus; // <1>
|
||||
----
|
||||
<1> Use _Assistant > Organize Imports, and be sure to import the correct `EventBus` class - which is `io.vertx.axle.core.eventbus.EventBus`.
|
||||
<1> Use _Assistant > Organize Imports_, and be sure to import the correct `EventBus` class - which is `io.vertx.axle.core.eventbus.EventBus`.
|
||||
|
||||
Next, create two new endpoints in the same class which creates new people in our database given a name, and finds people by their name:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Let’s now produce a native executable for our application. It improves the sta
|
||||
|
||||
GraalVM is a universal virtual machine for compiling and running applications written in JavaScript, Python, Ruby, R, JVM-based languages like Java, Scala, Groovy, Kotlin, Clojure, and LLVM-based languages such as C and C++. It includes ahead-of-time compilation, aggressive dead code elimination, and optimal packaging as native binaries that moves a lot of startup logic to _build-time_, thereby reducing startup time and memory resource requirements significantly.
|
||||
|
||||
image::[nativearch.png, native, 600]
|
||||
image::nativearch.png[native, 600]
|
||||
|
||||
GraalVM is already installed for you. Inspect the value of the `GRAALVM_HOME` variable in the Terminal with:
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ So let's add a bit more documentation to our `/person/birth/before/{year}` endpo
|
||||
|
||||
Add a few annotations:
|
||||
|
||||
**1. Add an `@Operation` annotation on the method to provide a brief summary and description. You'll need to _Assistant > Organize Imports_ to complete the import statements after adding the code:**
|
||||
**1. Add an `@Operation` annotation on the `getBeforeYear` method to provide a brief summary and description. You'll need to _Assistant > Organize Imports_ to complete the import statements after adding the code:**
|
||||
|
||||
[source,java,role="copypaste"]
|
||||
----
|
||||
@@ -172,7 +172,31 @@ Add a few annotations:
|
||||
|
||||
Again, _Assistant > Organize Imports_ (and make sure to import the right `Parameter` class: `org.eclipse.microprofile.openapi.annotations.parameters.Parameter`)
|
||||
|
||||
Now reload the same Swagger UI webpage. Notice the Swagger documention is more filled out for the endpoint to which we added extra OpenAPI documentation:
|
||||
The final method should look like:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Operation(summary = "Finds people born before a specific year",
|
||||
description = "Search the people database and return a list of people born before the specified year")
|
||||
@APIResponses(value = {
|
||||
@APIResponse(responseCode = "200", description = "The list of people born before the specified year",
|
||||
content = @Content(
|
||||
schema = @Schema(implementation = Person.class)
|
||||
)),
|
||||
@APIResponse(responseCode = "500", description = "Something bad happened")
|
||||
})
|
||||
@GET
|
||||
@Path("/birth/before/{year}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public List<Person> getBeforeYear(
|
||||
@Parameter(description = "Cutoff year for searching for people", required = true)
|
||||
@PathParam(value = "year") int year) {
|
||||
|
||||
return Person.getBeforeYear(year);
|
||||
}
|
||||
----
|
||||
|
||||
Now reload the same Swagger UI webpage (and expand the `/person/birth/before/{year}` section). Notice the Swagger documention is more filled out for the endpoint to which we added extra OpenAPI documentation:
|
||||
|
||||
image::swaggerparams.png[swaggerparams,600]
|
||||
|
||||
|
||||
@@ -168,6 +168,8 @@ image::importsql.png[importsql,800]
|
||||
|
||||
image::importsqlfile.png[importsqlfile,600]
|
||||
|
||||
Add these lines to `import.sql` file you just created:
|
||||
|
||||
[source,sql,role="copypaste"]
|
||||
----
|
||||
INSERT INTO person(id, name, birth, eyes) VALUES (nextval('hibernate_sequence'), 'Farid Ulyanov', to_date('1974-08-15', 'YYYY-MM-dd'), 'BLUE')
|
||||
|
||||
@@ -195,7 +195,7 @@ public interface StarWarsService {
|
||||
<4> The Star Wars API requires a `User-Agent` header, so with Quarkus we add that with `@ClientHeaderParam`. Other parameters can be added here as needed.
|
||||
<5> The `getPerson` method gives our code the ability to query the Star Wars API by `id`. The client will handle all the networking and marshalling leaving our code clean of such technical details.
|
||||
|
||||
=== Configure endppint
|
||||
=== Configure endpoint
|
||||
|
||||
In order to determine the base URL to which REST calls will be made, the REST Client uses configuration from `application.properties`. To configure it, add this to your `application.properties` (in `src/main/resource`):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user