= 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

. 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.

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 -jar ./target/*-runner.jar -Dquarkus.http.port=8081
----

[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/*-runner.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 -Dquarkus.profile=native
----
+
. Run the native executable:
+
[source, shell]
----
$ ./target/*-runner
----

=== 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].
