blob: 64fc6a429b4ecbcea30c7d26486e6b857fd0eb25 [file] [log] [blame]
= Vaccination scheduling (Java, Quarkus, Maven)
Assign people to vaccination injection appointments over time at vaccination centers to end a pandemic sooner.
image::../../build/quickstarts-showcase/src/main/resources/META-INF/resources/screenshot/quarkus-vaccination-scheduling-screenshot.png[]
* <<run,Run the application>>
* <<package,Run the packaged application>>
* <<cloud,Host it in the cloud>>
* <<native,Run it native>>
[[run]]
== Run the application
. Git clone the optaplanner-quickstarts repo and navigate to this directory:
+
[source, shell]
----
$ git clone https://github.com/kiegroup/optaplanner-quickstarts.git
...
$ cd optaplanner-quickstarts/use-cases/vaccination-scheduling
----
. Start the application with Maven:
+
[source, shell]
----
$ mvn quarkus:dev
----
. Visit http://localhost:8080 in your browser.
. Click on the *Solve* button.
Then try _live coding_:
. Make some changes in the source code.
. Refresh your browser (F5).
Notice that those changes are immediately in effect.
[[package]]
== Run the packaged application
When you're done iterating in `quarkus:dev` mode,
package the application to run as a conventional jar file.
. Compile it with Maven:
+
[source, shell]
----
$ mvn package
----
. Run it:
+
[source, shell]
----
$ java -jar ./target/quarkus-app/quarkus-run.jar
----
+
[NOTE]
====
To run it on port 8081 instead, add `-Dquarkus.http.port=8081`.
====
. Visit http://localhost:8080 in your browser.
. Click on the *Solve* button.
[[cloud]]
== Host it in the cloud
To allow others to try this application in their browser,
host it in the cloud and share the url with them.
=== Host it on OpenShift (Kubernetes)
https://www.redhat.com/en/technologies/cloud-computing/openshift[Red Hat OpenShift] is an open source Kubernetes cloud service
which is ideal to host OptaPlanner applications.
To deploy the application on OpenShift:
. https://developers.redhat.com/developer-sandbox[Get a free Developer Sandbox account for OpenShift] and _launch_ the Developer Sandbox.
. In the OpenShift web console, verify that the top left combobox is set to _Developer_ (not _Administrator_).
. In the menu, select *Add* to create an application.
. Under *Git Repository*, click *Import from Git* and fill in these parameters:
.. Set *Git Repo URL* to `https://github.com/kiegroup/optaplanner-quickstarts`
.. Under _Show advanced Git options_, set *Context dir* to `/use-cases/vaccination-scheduling`
.. Press the *Create* button.
. In the _Topology_ view, there is a new deployment:
.. Wait a minute until the build completes (watch the bottom left icon until it turns green).
.. Open the URL (click on the top right icon).
. Click on the *Solve* button.
=== Host it on OpenShift using native build
Requirements:
- Install https://podman.io/[Podman] or https://www.docker.com/[Docker]
- Install https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/getting-started-cli.html[OpenShift Client (oc) tools]
To deploy the application on OpenShift using the native build:
. https://developers.redhat.com/developer-sandbox[Get a free Developer Sandbox account for OpenShift] and _launch_ the Developer Sandbox.
. In the OpenShift web console, verify that the top left combobox is set to _Developer_ (not _Administrator_).
. In the OpenShift web console, click your username (in the upper right corner) and select the "Copy login command" option.
. In a bash terminal on your local machine, paste the login command.
. In a local clone of the repo, navigate to the `use-cases/vaccination-scheduling` directory.
. Run the command below:
+
[source, shell]
----
$ mvn clean package -DskipTests -Dopenshift-native -Dquarkus.kubernetes.deploy=true -Dquarkus.native.container-build=true
----
+
. When the command is finished, you should see one pod in the Topology view: the _native_ Quarkus application. If you click the Quarkus' application link (small bubble with link icon at the top right of the Quarkus' application bubble), you will be navigated to the application. Alternatively, you can get the route from bash with the following command:
+
[source, shell]
----
$ oc get routes
----
[[native]]
== Run it native
To increase startup performance for serverless deployments,
build the application as a native executable:
. https://quarkus.io/guides/building-native-image#configuring-graalvm[Install GraalVM and gu install the native-image tool]
. Compile it natively. This takes a few minutes:
+
[source, shell]
----
$ mvn package -Dnative -DskipTests
----
. Run the native executable:
+
[source, shell]
----
$ ./target/*-runner
----
. Visit http://localhost:8080 in your browser.
. Click on the *Solve* button.
== More information
Visit https://www.optaplanner.org/[www.optaplanner.org].