Please refer to Appendix A, Preparing the Environment and Running Code Samples, if you still have to install Java and/or SBT.
We will run our application in the terminal the same way we did in Chapter 11, An Introduction to the Akka and Actor Models and Chapter 12, Building Reactive Applications with Akka Typed, using two separate terminal sessions for Store and BakeryApp using the following commands:
- sbt "runMain ch13.BakeryApp"
- sbt "runMain ch13.Store"
We prefer this method because of its conciseness. If you're about to run the app in interactive mode, please consult Chapter 11, An Introduction to the Akka and Actor Models, for a detailed explanation of this approach.
In our examples, we expect the remote Store app to be available at the moment we start the main Bakery stream. Because of this, we have to start the Store first or the BakeryApp will exit with an exception at the moment it fails to connect to the store. The next screenshot shows two terminal windows with commands to run the Store entered in the left window and the BakeryApp started in the right window. In the following screenshot, we can see that the Store has already been running for some time and the BakeryApp has just started to execute:
The Bakery in the right terminal will now run until stopped with the Ctrl + C shortcut or the terminal window is closed.