= School Timetabling (Java, ActiveMQ, Quarkus, Maven)

The quickstart consists of two modules:

* Client runs the UI and sends requests to the Solver Server via ActiveMQ.
* Solver Server optimizes the requests sent via an ActiveMQ queue and sends results back to ActiveMQ broker.

== Run the application with live coding

. Git clone the optaplanner-quickstarts repo:
+
[source, shell]
----
$ git clone https://github.com/kiegroup/optaplanner-quickstarts.git
...
$ cd optaplanner-quickstarts/technology/java-activemq-quarkus
----

. Build the project:
+
[source, shell]
----
$ mvn clean install
----
+

. Install https://docs.docker.com/get-docker/[docker] and https://docs.docker.com/compose/install/[docker-compose].

. Start the ActiveMQ broker, the Solver Server, and Client application with the `run.sh` script, which starts all 3 processes:
+
[source, shell]
----
$ ./run.sh
----
+

. Visit http://localhost:8080 in your browser.

. Click on the *Solve* button.

In case of any error, please check the log files located in `java-activemq-quarkus/target`.

Then try _live coding_:

. Make some changes in the source code.
. Refresh your browser (F5).

Notice that those changes are immediately in effect.

== Package and run the application

When you're done iterating in `quarkus:dev` mode, run the application as a conventional jar file.
Before running any application, start the ActiveMQ broker:

[source, shell]
----
$ docker-compose up
----

=== Package and run the Solver Server application

. Compile it with Maven:
+
[source, shell]
----
$ cd solver
$ mvn package -DskipTests
----
+
. Run it:
+
[source, shell]
----
$ java -Dquarkus.http.port=8081 -jar ./target/quarkus-app/quarkus-run.jar
----

[NOTE]
Use the custom port to avoid conflict with the Client application.

=== Package and run the Client application

. Compile it with Maven:
+
[source, shell]
----
$ cd client
$ mvn package -DskipTests
----
+
. Run it:
+
[source, shell]
----
$ java -jar ./target/quarkus-app/quarkus-run.jar
----
+

. Visit http://localhost:8080 in your browser.

== Run a native executable

First, https://quarkus.io/guides/building-native-image#configuring-graalvm[install GraalVM and gu install the native-image tool]

=== Compile and run the Solver Server application natively

. Compile the Solver Server application natively:
+
[source, shell]
----
$ cd solver
$ mvn package -Dnative -DskipTests
----
+
. Run the native executable:
+
[source, shell]
----
$ ./target/*-runner -Dquarkus.http.port=8081
----

=== Compile and run the Client application natively

. Compile the Client application natively:
+
[source, shell]
----
$ cd client
$ mvn package -Dnative -DskipTests
----

. Run the native executable:
+
[source, shell]
----
$ ./target/*-runner
----

. Visit http://localhost:8080 in your browser.

== More information

Visit https://www.optaplanner.org/[www.optaplanner.org].
