diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/01-01-add-extension/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/01-01-add-extension/assignment.md index 9d08379e..f72fb44c 100755 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/01-01-add-extension/assignment.md +++ b/instruqt-tracks/developing-with-quarkus-reactive-sql/01-01-add-extension/assignment.md @@ -154,4 +154,4 @@ You've initialized the demonstration application. ---- -**NEXT:** Deploying the demonstration application and database into Red Hat OpenShift \ No newline at end of file +**NEXT:** Deploying the demonstration application and database into Red Hat OpenShift diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/02-02-remote-dev/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/02-02-remote-dev/assignment.md deleted file mode 100755 index 8a3f7166..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/02-02-remote-dev/assignment.md +++ /dev/null @@ -1,378 +0,0 @@ ---- -slug: 02-remote-dev -id: x77axevyzlyd -type: challenge -title: Topic 2 - Deploying the demonstration application and backing database into - Red Hat OpenShift -notes: -- type: text - contents: Topic 2 - Deploying the demonstration application and backing database - into Red Hat OpenShift -tabs: -- title: Terminal 1 - type: terminal - hostname: crc -- title: Visual Editor - type: code - hostname: crc - path: /root/projects/rhoar-getting-started/quarkus/reactive-sql -- title: OpenShift Web Console - type: website - url: https://console-openshift-console.crc-lgph7-master-0.crc.${_SANDBOX_ID}.instruqt.io - new_window: true -difficulty: intermediate -timelimit: 240 ---- -# Understanding Remote Live Coding - -A key feature of Quarkus is the ability to configure an application in remote development mode so that making changes to local files will immediately cascade into the remote container environment that hosts the application while the application is running. - -The changes made locally are visible immediately on the remote deployment running on OpenShift. - -This feature is called Live Coding. - -Live Coding allows you to develop code and services running remotely in real time. - -In this track you'll deploy the demonstration application to OpenShift and connect it to your local environment. The end result will be a fully functional application that's already running on the OpenShift target platform. - -# Accessing the OpenShift web console - -OpenShift ships with a web console that allows users to perform tasks via a browser. - ----- - -`Step 1a:` Click the **OpenShift Web Console** tab on the horizontal menu bar over the console window to the left to view the login screen. - -|NOTE:| -|----| -|You might see the following warning notification due to using an untrusted security certificate. -![Security warning](../assets/security_warning.png) -If you do get the warning, click the **Advanced** button to complete the process necessary to grant permission to the browser to access the OpenShift web console.| - -`Step 1b:` Log in using the following credentials as shown in the figure below: - -* Username: `developer` -* Password: `developer` - -![login](../assets/web-console-login.png) - -`Step 1c:` Click the **Skip Tour** button to skip the new user introduction. - ----- - -`Step 2:` Run the following command in **Terminal 1** to log in with the OpenShift CLI: - -``` -oc login -u developer -p developer -``` - -You will see the following output: - -``` -Login successful. - -You don't have any projects. You can try to create a new project, by running - - oc new-project -``` - -# Accessing the OpenShift project - -In this track, you will create a project in OpenShift to host the demonstration application and the associated PostgresSQL database. - ----- - -`Step 3:` Run the following command in **Terminal 1** to create a `reactive-sql` project with the display name `ReactiveSQL with Quarkus`: - -``` -oc new-project reactive-sql --display-name="ReactiveSQL with Quarkus" -``` - -You will get output similar to the following: - -``` -Now using project "reactive-sql" on server "https://api.crc.testing:6443". - -You can add applications to this project with the 'new-app' command. For example, try: - - oc new-app rails-postgresql-example - -to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application: - - kubectl create deployment hello-node --image=k8s.gcr.io/serve_hostname -``` - ----- - -`Step 4:` Return to the **OpenShift Web Console** and click the **Topology** button on the vertical menu bar on the left. Then, click the link -`reactive-sql`. You'll be presented with a page displaying the text `No resources found` as shown in the figure below. - -![No resources found](../assets/no-resources-found.png) - - -# Deploying the PostgresSQL database - -`Step 5:` Run the following command in **Terminal 1** to to deploy a PostgresSQL database instance to the new project: - -``` -oc new-app \ - -e POSTGRESQL_USER=username \ - -e POSTGRESQL_PASSWORD=password \ - -e POSTGRESQL_DATABASE=sampledb \ - --name=database \ - -l app.openshift.io/runtime=postgresql \ - openshift/postgresql -``` - -You'll see the following output: - -``` ---> Found image d41bd78 (8 months old) in image stream "openshift/postgresql" under tag "13-el8" for "openshift/postgresql" - - PostgreSQL 13 - ------------- - PostgreSQL is an advanced Object-Relational database management system (DBMS). The image contains the client and server programs that you'll need to create, run, maintain and access a PostgreSQL DBMS server. - - Tags: database, postgresql, postgresql13, postgresql-13 - - ---> Creating resources with label app.openshift.io/runtime=postgresql ... - deployment.apps "database" created - service "database" created ---> Success - Application is not exposed. You can expose services to the outside world by executing one or more of the commands below: - 'oc expose service/database' - Run 'oc status' to view your app. -``` - - ----- - -`Step 6:` Return to the **OpenShift Web Console** tab. You'll see the Postgres pod spinning up from the Topology view in the web console as shown in the figure below. - -![Postgres pod](../assets/database-in-openhift.png) - -# Adding the Quarkus OpenShift extension - -Quarkus offers the ability to automatically generate OpenShift resources based on both default and user supplied configuration settings. - -The OpenShift extension is actually a wrapper extension that brings together the [Kubernetes](https://quarkus.io/guides/deploying-to-kubernetes) and [container-image-s2i](https://quarkus.io/guides/container-image#s2i) extensions. - ----- - -`Step 7:` Run the following command in **Terminal 1** to add the OpenShift extension to the Quarkus project: - -``` -mvn quarkus:add-extension -Dextensions="openshift" -f /root/projects/rhoar-getting-started/quarkus/reactive-sql -``` - -You will see output similar to the following: - -``` -[INFO] Scanning for projects... -[INFO] -[INFO] -------------------< org.acme.reactive:reactive-sql >------------------- -[INFO] Building reactive-sql 1.0.0-SNAPSHOT -[INFO] --------------------------------[ jar ]--------------------------------- -[INFO] -[INFO] --- quarkus-maven-plugin:xx.xx.xx:add-extension (default-cli) @ reactive-sql --- -[INFO] [SUCCESS] ? Extension io.quarkus:quarkus-openshift has been installed -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -``` - -# Configuring Quarkus for Remote Live Coding - -`Step 8a:` Go the **Visual Editor** tab on the horizontal menu bar over the console window to the left. - -`Step 8b:` Navigate to the file `src/main/resources/application.properties` as shown in the figure below. - -![To application properties](../assets/to-application-properties.png) - -`Step 8c:` Click on the file `src/main/resources/application.properties` to open it for editing. - -`Step 8d:` Copy and paste the following values to the end of the `application.properties` file: - -```java -# Remote Live Coding setup -quarkus.package.type=mutable-jar -quarkus.live-reload.password=changeit - -# OpenShift Production Configuration -quarkus.datasource.db-kind=postgresql -quarkus.datasource.reactive.url=postgresql://database:5432/sampledb -quarkus.datasource.username=username -quarkus.datasource.password=password -``` - -|NOTE:| -|----| -|You can change the remote live-reload username/password pair defined by `quarkus.datasource.username` and `quarkus.datasource.password` in the `application.properties` file to whatever you want. Those credentials are used to secure communication between the remote side and the local side. - -`Step 8e:` Click on the `Disk` icon or press `CTRL+S` to save the file as shown in the figure below: - -![Save properties](../assets/save-properties-01.png) - - -**KEY POINTS TO UNDERSTAND** - -* The `quarkus.package.type=mutable-jar` setting in the `application.properties` file instructs Quarkus to package the application as a `mutable application`. -* Mutable applications include the parts that Quarkus needs at deployment times and also to support `dev` mode. As a result, a `mutable application` can take up a bit more disk space. -* When a `mutable application` is **not** run in `dev mode` it starts just as fast and uses the same memory as an immutable application. -* You can configure Quarkus to use the Postgres database using the term `database` as the hostname, as shown below in Step 9 for the parameter `-Dquarkus.openshift.annotations.\"app.openshift.io/connects-to\"=database`. OpenShift will resolve the hostname `database` to the running Postgres database. - -# Deploying the demonstration application to OpenShift - -`Step 9:` Run the following command in **Terminal 1** to build and deploy the demonstration Quarkus application in OpenShift: - -``` -mvn clean package -DskipTests -f /root/projects/rhoar-getting-started/quarkus/reactive-sql \ --Dquarkus.kubernetes.deploy=true \ --Dquarkus.kubernetes-client.trust-certs=true \ --Dquarkus.kubernetes.deployment-target=openshift \ --Dquarkus.openshift.route.expose=true \ --Dquarkus.openshift.annotations.\"app.openshift.io/connects-to\"=database \ --Dquarkus.openshift.env.vars.QUARKUS_DATASOURCE_DEVSERVICES=false \ --Dquarkus.openshift.env.vars.quarkus-launch-devmode=true -``` - -There will be a lot of output to the screen. The installation might take a minute or two. - -Eventually, upon a successful installation, you will get output similar to the following: - -``` -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -``` - -**KEY POINTS TO UNDERSTAND** - -* `quarkus.kubernetes.deploy=true` - Indicates the extension to deploy to OpenShift after the container image is built. -* `quarkus.kubernetes-client.trust-certs=true` - Indicates that the application is using self-signed certs. Quarkus will trust the certificates by default. -* `quarkus.kubernetes.deployment-target=openshift` - Indicates the extension to generate and create the OpenShift resources after building the container. Examples of OpenShift resources are `DeploymentConfig`s and `Service`s. -* `quarkus.openshift.route.expose=true` - Indicates the extension to generate an OpenShift `Route` so that the application is accessible from a browser. -* `quarkus.kubernetes.annotations."app.openshift.io/connects-to"=database` - Adds a visual connector to show the DB connection in the web console topology view. -* `quarkus.openshift.env.vars.QUARKUS_DATASOURCE_DEVSERVICES=false` - Disables Quarkus dev services because these are not needed on OpenShift. -* `quarkus.openshift.env.vars.quarkus-launch-devmode=true` - Sets an environment variable in the container to tell Quarkus to launch in `dev mode`, not production mode, which is the default when deploying to Kubernetes or OpenShift. - ----- - -`Step 10:` Run the following command in **Terminal 1** to verify that the application rollout has been completed: - -``` -oc rollout status -w dc/reactive-sql -``` - -Eventually you will see the following output: - -``` -Waiting for rollout to finish: 0 of 1 updated replicas are available... -Waiting for latest deployment config spec to be observed by the controller loop... -replication controller "reactive-sql-1" successfully rolled out -``` - -|NOTE| -|----| -|If the `oc rollout` command appears to not be finishing, press the `CTRL-C` keys to cancel the process. Then run the command again.| - ----- - -`Step 11:` Return to the **OpenShift Web Console** tab. You will see two circular graphics indicating that both the PostgresSQL database and Quarkus reactive application are running, as shown in the figure below. - -![Apps are runnning](../assets/react-app-running.png) - ----- - -`Step 12:` Run the following command in **Terminal 1** extract the application's Route from the Topology view: - -``` -export APP_ROUTE=`oc get route reactive-sql -n reactive-sql -o jsonpath='{"http://"}{.spec.host}'` -echo $APP_ROUTE -``` - -You'll get output similar to the following: - -``` -http://reactive-sql-reactive-sql.crc-lgph7-master-0.crc.hbie33wmyvpb.instruqt.io -``` - -(The actual details of your URL will differ because each running instance of OpenShift will have a unique URL.) - -|NOTE| -|----| -|It may take a few seconds for the app to work and the networking to get glued together. If the web page doesn't appear, reload the browser until it does.| - ----- - -`Step 13:` Copy and past the URL returned from the `oc get route...` command in to the address bar in a browser window. You will see a web page like so: - -![Coffee App Web Page](../assets/coffee-web-page-01.png) - -The demonstration application is now up and running. - -Leave the demonstration application running in order to experiment with using Quarkus' Remote Live Reload feature to automatically update the application as you make changes. - -# Connecting the demonstration application in remote dev mode - -You are now ready to run the demonstration application in `dev mode` and connect it to the remote instance running in OpenShift. - ----- - -`Step 14:` Run the following command in **Terminal 1** to connect to the demonstration application in `dev mode`: - -``` -mvn quarkus:remote-dev -Dquarkus.live-reload.url=$APP_ROUTE -f /root/projects/rhoar-getting-started/quarkus/reactive-sql -``` - -You will see output similar to the following snippet of code: - -``` -[INFO] Scanning for projects... -[INFO] -[INFO] -------------------< org.acme.reactive:reactive-sql >------------------- -[INFO] Building reactive-sql 1.0.0-SNAPSHOT -[INFO] --------------------------------[ jar ]--------------------------------- -[INFO] -[INFO] --- quarkus-maven-plugin:xx.xx.xx:remote-dev (default-cli) @ reactive-sql --- -[INFO] Using 'UTF-8' encoding to copy filtered resources. -. -. -. -``` - -The command entered in **Terminal 1** will start the application in `dev mode`. The **Terminal 1** window will keep running the process. You won't be able execute commands in **Terminal 1**. - -However, you can make code changes using the **Visual Editor**. The changes you make in **Visual Editor** will show up immediately in the remote instance of the application running on OpenShift. - - -# Updating the demonstration application using Live Coding - -Let's modify the demonstration application's web page by making a change to the file, `src/main/resources/META-INF/resources/index.html`. - -You'll add the text ` - Remote Dev` to the banner text. - ----- - -`Step 15a:` Using the **Visual Editor**, navigate to the file `src/main/resources/META-INF/resources/index.html`. - -`Step 15c:` At `Line 110` change the text from `Quarkus Reactive SQL Coffee Shop` to `Quarkus Reactive SQL Coffee Shop - Remove Dev` as shown in the figure below. - -![Change text](../assets/change-banner-01.png) - -`Step 15d:` Click on the `Disk` icon or press `CTRL+S` to save the file. - ----- - -`Step 16:` Return to the web browser window where you loaded the demonstration application's web page. You will see that the HTML page on OpenShift has updated automatically as shown in the figure below. - -![Updated web page](../assets/web-page-updated.png) - -# Congratulations! - -You've learned how to set up a remote connection to the demonstration application, enabling Live Coding as it runs in OpenShift - ----- - -**NEXT:** Creating the reactive CoffeeResource endpoints \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-02-remote-dev/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/03-02-remote-dev/assignment.md index 7b1346b1..e5b06390 100755 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-02-remote-dev/assignment.md +++ b/instruqt-tracks/developing-with-quarkus-reactive-sql/03-02-remote-dev/assignment.md @@ -378,4 +378,4 @@ You've learned how to set up a remote connection to the demonstration applicatio ---- -**NEXT:** Creating the reactive CoffeeResource endpoints \ No newline at end of file +**NEXT:** Creating the reactive CoffeeResource endpoints diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/assignment.md deleted file mode 100755 index 9f85ce8e..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/assignment.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -slug: 03-add-resource -id: jkic6vwct0mz -type: challenge -title: Topic 3 - Creating the reactive CoffeeResource endpoints -notes: -- type: text - contents: Topic 3 - Creating the reactive CoffeeResource endpoints -tabs: -- title: Terminal 1 - type: terminal - hostname: crc -- title: Visual Editor - type: code - hostname: crc - path: /root/projects/rhoar-getting-started/quarkus/reactive-sql -difficulty: basic -timelimit: 240 ---- -In the previous topic you created a PostgreSQL database for the demonstration application. Also you added the extensions to Quarkus. - -In this topic you will add RESTful endpoints to the `CoffeeResource`. You'll modify the application and add relevant methods. - -The `CoffeeResource` is already provided in the demonstration application's source code. The work to be done is to add additional functionality to the existing source code. - -First you'll add code that will automatically create a table in the PostgresSQL database and insert three types of coffee, `Americano`, `Latte`, and `Mocha`. - ----- - -`Step 1a:` In the **Visual Editor**, navigate to the file `src/main/java/org/acme/reactive/CoffeeResource.java` as shown in the figure below. - -![Open Coffee Resource](../assets/open-coffeesource.png) - -`Step 1b:` Click on the file `src/main/java/org/acme/reactive/CoffeeResource.java` to open it for editing. - -`Step 1c:` Copy and paster the following code after the comment `// TODO initdb`: - -```java - client.query("DROP TABLE IF EXISTS coffee").execute() - .flatMap(r -> client.query("CREATE TABLE coffee (id SERIAL PRIMARY KEY, name TEXT NOT NULL)").execute()) - .flatMap(r -> client.query("INSERT INTO coffee (name) VALUES ('Americano')").execute()) - .flatMap(r -> client.query("INSERT INTO coffee (name) VALUES ('Latte')").execute()) - .flatMap(r -> client.query("INSERT INTO coffee (name) VALUES ('Mocha')").execute()).await() - .indefinitely(); -``` - -`Step 1d:` Click on the `Disk` icon or press `CTRL+S` to save the file. - -Next, you'll add the RESTful API methods. You'll add a `GET` method that sill return all coffee types. Also, you'll add `GET` method that returns a specific coffee type according to `id`. - -The `getSingle` method that returns a single coffee type uses the `PathParam` to indicate the the `id` passed from the query string value defined by the `@Path` annotation. - ----- - -`Step 2a:` Add the following code after the `// TODO GET` comment: - -```java - @GET - public Multi get() { - return Coffee.findAll(client); - } - - @GET - @Path("{id}") - public Uni getSingle(@PathParam("id") Long id) { - return Coffee.findById(client, id) - .onItem().transform(fruit -> fruit != null ? Response.ok(fruit) : Response.status(Status.NOT_FOUND)) - .onItem().transform(ResponseBuilder::build); - } - -``` - -`Step 2b:` Click on the `Disk` icon or press `CTRL+S` to save the file. - -Now add the `POST` and `PUT` request methods. - ----- - -`Step 3a:` Add the following code after the `// TODO POST` comment: - -```java - - @POST - public Uni create(Coffee coffee) { - return coffee.save(client) - .onItem().transform(id -> URI.create("/coffee/" + id)) - .onItem().transform(uri -> Response.created(uri).build()); - } - - @PUT - @Path("{id}") - public Uni update(@PathParam("id") Long id, Coffee coffee) { - return coffee.update(client) - .onItem().transform(updated -> updated ? Status.OK : Status.NOT_FOUND) - .onItem().transform(status -> Response.status(status).build()); - } -``` - -`Step 3b:` Click on the `Disk` icon or press `CTRL+S` to save the file. - -Finally add the DELETE method, so that there's an endpoint for deleting a coffee type from the Quarkus demonstration application. - ----- - -`Step 4a:` Add the following code after the `// TODO DELETE` comment: - -```java - @DELETE - @Path("{id}") - public Uni delete(@PathParam("id") Long id) { - return Coffee.delete(client, id) - .onItem().transform(deleted -> deleted ? Status.NO_CONTENT : Status.NOT_FOUND) - .onItem().transform(status -> Response.status(status).build()); - } -``` - -`Step 4b:` Click on the `Disk` icon or press `CTRL+S` to save the file. - -# Congratulations! - -You've added the `coffee` type data to the PostgresSQL database. Also, you created `GET`, `POST`, `PUT` and `DELETE` endpoints to the demonstration application - -**NEXT:** Modifying the `Coffee` class \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/setup-crc b/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/setup-crc deleted file mode 100755 index 3302da1c..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/03-03-add-resource/setup-crc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -kill -9 $(ps aux | grep reactive-sql | grep -v grep | awk '{print $2}') -export APP_ROUTE=`oc get route reactive-sql -n reactive-sql -o jsonpath='{"http://"}{.spec.host}'` -echo ${APP_URL} -nohup mvn quarkus:remote-dev -Dquarkus.live-reload.url=$APP_ROUTE -f /root/projects/rhoar-getting-started/quarkus/reactive-sql > /root/log.out 2> /root/log.err < /dev/null & disown \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-03-add-resource/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/04-03-add-resource/assignment.md index 2586a2a8..ed35b9d4 100755 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-03-add-resource/assignment.md +++ b/instruqt-tracks/developing-with-quarkus-reactive-sql/04-03-add-resource/assignment.md @@ -122,4 +122,4 @@ Finally add the DELETE method, so that there's an endpoint for deleting a coffee You've added the `coffee` type data to the PostgresSQL database. Also, you created `GET`, `POST`, `PUT` and `DELETE` endpoints to the demonstration application -**NEXT:** Modifying the `Coffee` class \ No newline at end of file +**NEXT:** Modifying the `Coffee` class diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/assignment.md deleted file mode 100755 index faa52c6e..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/assignment.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -slug: 04-add-model -id: yvk6uux5dqrw -type: challenge -title: Topic 4 - Modifying the Coffee class -notes: -- type: text - contents: Topic 4 - Modifying the Coffee class -tabs: -- title: Terminal 1 - type: terminal - hostname: crc -- title: Visual Editor - type: code - hostname: crc - path: /root/projects/rhoar-getting-started/quarkus/reactive-sql -difficulty: basic -timelimit: 240 ---- -Previously you added coffee type data to the PostgresSQL database. Also, you created `GET`, `POST`, `PUT` and `DELETE` endpoints to the demonstration application. - -In this topic you will build out the `Coffee` class by inserting a method that will retrieve a particular coffee type according to a specific `id`. - -First, let's analyze the existing code. - ----- - -`Step 1:` Using the **Visual Editor**, navigate to the file `src/main/java/org/acme/reactive/Coffee.java` as shown in the figure below: - -![Open coffee](../assets/open-coffee.png) - -Notice that the `Coffee` class has only fields as shown in the code snippet below: - -```java - - public Long id; - - public String name; - -``` - -The `Coffee` class represents a data entity for a coffee type. Thus, having the fields `id` and `name` makes sense. The field `id` is the unique identifier of the coffee record in the PostgresSQL database. The `name` field describes the name of the coffee type, for example `Americano`. - ----- - -`Step 2:` In the **Visual Editor**, scroll through the file `src/main/java/org/acme/reactive/Coffee.java`. - -Notice that the `Coffee` class has the methods `findAll(PgPool client)`, `save(PgPool client)`, `update(PgPool client)`, and `delete(PgPool client, Long id)`. These methods do the work of getting all coffee types from the PostgresSQL database, as well as saving, updating, and deleting a particular coffee type. All of the methods use a [`PgPool`](https://pgpool.net/mediawiki/index.php/Main_Page) object since we are going to use a PostgreSQL database and are using the PostgreSQL reactive driver. - -The outstanding work is to add intelligence to the `Coffee` class that will enable the class to retrieve a particular coffee type according to `id`. You'll add this intelligence now by inserting a method named `findById()`. - ----- - -`Step 3a:` In the **Visual Editor**, click on the file `src/main/java/org/acme/reactive/Coffee.java` to open it for editing. - -`Step 3b:` Add this content after the `// TODO FindById` comment: - -```java - public static Uni findById(PgPool client, Long id) { - return client.preparedQuery("SELECT id, name FROM coffee WHERE id = $1").execute(Tuple.of(id)) - .onItem().transform(RowSet::iterator) - .onItem().transform(iterator -> iterator.hasNext() ? from(iterator.next()) : null); - } -``` -`Step 3c:` Click on the `Disk` icon or press `CTRL+S` to save the file. - -Notice that an `PgPool` object is passed to the `findById()` method as the type of the `client` parameter. - -The `client` does the work of preparing the query and applying successive `onItem` reactive methods to transform the result. The result is returned as a `Uni` as part of the demonstration application's Mutiny reactive API. - - -# Congratulations! - -You've reviewed and upgraded the data access classes in the demonstration application. - ----- - -**NEXT:** Redeploying the demonstration application instance running on OpenShift \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/setup-crc b/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/setup-crc deleted file mode 100755 index 3302da1c..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/04-04-add-model/setup-crc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -kill -9 $(ps aux | grep reactive-sql | grep -v grep | awk '{print $2}') -export APP_ROUTE=`oc get route reactive-sql -n reactive-sql -o jsonpath='{"http://"}{.spec.host}'` -echo ${APP_URL} -nohup mvn quarkus:remote-dev -Dquarkus.live-reload.url=$APP_ROUTE -f /root/projects/rhoar-getting-started/quarkus/reactive-sql > /root/log.out 2> /root/log.err < /dev/null & disown \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-04-add-model/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/05-04-add-model/assignment.md index be562eb9..7425094b 100755 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-04-add-model/assignment.md +++ b/instruqt-tracks/developing-with-quarkus-reactive-sql/05-04-add-model/assignment.md @@ -77,4 +77,4 @@ You've reviewed and upgraded the data access classes in the demonstration applic ---- -**NEXT:** Redeploying the demonstration application instance running on OpenShift \ No newline at end of file +**NEXT:** Redeploying the demonstration application instance running on OpenShift diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/assignment.md b/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/assignment.md deleted file mode 100755 index d3964abc..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/assignment.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -slug: 05-package-and-run -id: ojum6v7lxmay -type: challenge -title: Topic 5 - Redeploying the demonstration application into OpenShift -notes: -- type: text - contents: Topic 5 - Redeploying the demonstration application into OpenShift -tabs: -- title: Terminal 1 - type: terminal - hostname: crc -- title: Visual Editor - type: code - hostname: crc - path: /root/projects/rhoar-getting-started/quarkus/reactive-sql -difficulty: basic -timelimit: 240 ---- -In the previous topic you updated the `Coffee` class by adding a new method `findById()` method. In this topic you will redeploy the demonstration application release the additional data access capabilities. Also, you will see the results of the deployment in the demonstration application's web page. - ----- - -`Step 1:` Run the following command in the **Terminal 1** console window to redeploy the demonstration application: - -``` -cd /root/projects/rhoar-getting-started/quarkus/reactive-sql && \ - mvn clean package -DskipTests \ - -Dquarkus.kubernetes.deploy=true \ - -Dquarkus.kubernetes-client.trust-certs=true \ - -Dquarkus.kubernetes.deployment-target=openshift \ - -Dquarkus.openshift.route.expose=true \ - -Dquarkus.openshift.annotations.\"app.openshift.io/connects-to\"=database -``` - -There will be good deal of screen output. Eventually, upon a successful installation, you will see output similar to the following: - -``` -INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -``` - ----- - -`Step 2:` Run the following command in **Terminal 1** to verify that the rollout of the demonstration application was successful: - -``` -oc rollout status -w dc/reactive-sql -``` - -Eventually you will see output similar to the following: - -``` -Waiting for rollout to finish: 1 old replicas are pending termination... -Waiting for rollout to finish: 1 old replicas are pending termination... -Waiting for latest deployment config spec to be observed by the controller loop... -replication controller "reactive-sql-3" successfully rolled out -``` - -|NOTE| -|----| -|If the `oc rollout` command seems to not be finishing, press the `CTRL+C` keys to terminate the process. Then run `oc rollout` again. - - ----- - -`Step 3:` Run the following command in **Terminal 1** to get the demonstration application's Route URL: - -``` -oc get route reactive-sql -n reactive-sql -o jsonpath='{"http://"}{.spec.host}' -``` - ----- - -`Step 4:` Copy the URL from the output above command and paste it in a browser's address bar. - ----- - -`Step 5:` You will see new functionality added to the demonstration application's web page as shown in the figure below: - -![Updated Web Page](../assets/updated-web-page.png) - - -# Congratulations! - -This is the last topic in the track. - -You updated the demonstration application with additional capabilities. You learned a bit more about the mechanics of packaging, deploying and maintaining a Quarkus application. - -Also, in this tutorial you used JAX-RS and learned how to install the demonstration application in Red Hat OpenShift Container Platform. - -This is the last topic in this track. To read more about Quarkus and Reactive SQL go to the [QuarkusIO](http://www.quarkus.io) web site for more details. - ----- - -# BONUS SECTION: - -**Open the solution in an IDE in the Cloud!** - -Want to continue exploring this solution on your own in the cloud? - -You can use the free [Red Hat OpenShift Dev Spaces](https://developers.redhat.com/products/openshift-dev-spaces/overview) IDE running on the [Developer Sandbox for Red Hat OpenShift](http://red.ht/dev-sandbox) to get more insight into working with Quarkus and reactive programming. - -[Click here](https://workspaces.openshift.com) to register and log into Red Hat Workspaces. This free service expires after 30 days, but you can always renew a new free 30-day subscription. - -Once logged in, [click here](https://workspaces.openshift.com/f?url=https://raw.githubusercontent.com/openshift-katacoda/rhoar-getting-started/solution/quarkus/reactive-sql/devfile.yaml) to open the solution for this project in the cloud IDE. While loading, if the sandbox asks you to update or install any plugins, you can say no. - -# What's Next? - -Congratulations on completing this lab. Keep learning about OpenShift: - -* Visit the [Red Hat Developer learning page](https://developers.redhat.com/learn) for more labs and resources -* [Want to try a free, instant 30-day OpenShift cluster? Get started with the Developer Sandbox for Red Hat OpenShift](https://developers.redhat.com/developer-sandbox) - -Don't forget to finish the lab and rate your experience on the next page. Thanks for playing! diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/setup-crc b/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/setup-crc deleted file mode 100755 index fcaafbd6..00000000 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/05-05-package-and-run/setup-crc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -kill -9 $(ps aux | grep reactive-sql | grep -v grep | awk '{print $2}') \ No newline at end of file diff --git a/instruqt-tracks/developing-with-quarkus-reactive-sql/track.yml b/instruqt-tracks/developing-with-quarkus-reactive-sql/track.yml index 2dd1a274..2a8dbd6e 100755 --- a/instruqt-tracks/developing-with-quarkus-reactive-sql/track.yml +++ b/instruqt-tracks/developing-with-quarkus-reactive-sql/track.yml @@ -39,11 +39,10 @@ owner: openshift developers: - doh@redhat.com - bob@cogarttech.com -- dschenck@redhat.com - nvinto@redhat.com - eshortis@redhat.com -- ryanj@redhat.com - cclyburn@redhat.com +- ryanj@redhat.com sandbox_preset: openshift-411 lab_config: overlay: false @@ -52,4 +51,4 @@ lab_config: feedback_recap_enabled: true loadingMessages: true hideStopButton: false -checksum: "2603218897058024328" +checksum: "7878072425048305736"