Running the application

Please refer to  Appendix APreparing the Environment and Running Code Samples, if you don't have Java and SBT installed yet.

We will run our application in the terminal by using two separate terminal sessions for Shop and Bakery. It is possible to run both by issuing one of the two following commands in the corresponding shell:

  • sbt "runMain ch11.Store"
  • sbt "runMain ch11.Bakery"

In our code, we do not handle the StateTimeout for the Shopping/ShoppingList state. Therefore, it is mandatory to start the store session first and after it loads and starts to accept connections stating that the bakery session can be started. 

It is also possible to use an approach documented in Appendix APreparing the Environment and Running Code Samplesto run the code from within the SBT session and choose the appropriate main class after that. This approach is represented in the following screenshot:

Here, we can see how two SBT sessions are initiated in the ch11 folder. On the right-hand side of the screen, the main class for the store was already selected and run by SBT. The logs show that the Store is listening for connections, so it is safe to start the main Bakery session.

This happens after we enter 1 in the left Terminal window:

The store side reflects that the connection was established and the bakery side starts to output log statements about current activities. It keeps running and logging what is happening until stopped by pressing Ctrl + C.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.160.181