We began the betting-house example in chapter 12. There we had the three main actors representing the business: the bet, the market, and the wallet. The market is a specific sports event with odds to bet against. The wallet represents the account of a user with its balance. The bet is the amount of money invested in a market and backed by a wallet.
In this chapter, you add two projections: one for the markets and one for the bets. These projections transform some of the events they receive from the entities and push them—those from the markets into a Kafka topic, and those from the bets into a database (see figure 15.1).
This chapter shows how to add a database projection and a Kafka projection to the example project. Both read from the journal, but they differ on the writing side: the first writes to a database, and the second writes to Kafka. Now that you know Alpakka and Kafka (covered in chapter 14), this discussion should be easy for you.
NOTE
The source code for this chapter is available at www.manning.com/books/akka-in-action-second-edition or https://github.com/franciscolopezsancho/akka-topics/tree/main/betting-house. You can find the contents of any snippet or listing in the .scala file with the same name as the class, object, or trait.