concept operation in category kafka

appears as: operations, operations, operation, n operation
Kafka Streams in Action: Real-time apps and microservices with the Kafka Streams API

This is an excerpt from Manning's book Kafka Streams in Action: Real-time apps and microservices with the Kafka Streams API.

One downside of using the print() method is that it creates a terminal node, meaning you can’t embed it in a chain of processors. You need to have a separate statement. However, there’s also the KStream.peek method, which takes a ForeachAction instance as a parameter and returns a new KStream instance. The ForeachAction interface has one method, apply(), which has a return type of void, so nothing from KStream.peek is forwarded downstream, making it ideal for operations like printing. You can embed it in a chain of processors without the need for a separate print statement. You’ll see the KStream.peek method used in this manner in other examples in the book.

Figure 4.10. The ability to recover from failure is important for stream-processing applications. Kafka Streams persists data from the local in-memory stores to an internal topic, so when you resume operations after a failure or a restart, the data is repopulated.

Second, we’ll discuss the KTable. The KTable API is necessary because it’s designed to work with updates to records. We need the ability to work with updates for operations like aggregations and counts. We touched on updates in chapter 4 when introducing stateful transformations; in section 4.2.5, you updated the rewards processor to keep track of customer purchases.

Sometimes, you’ll want an ongoing aggregation and reduction of results like this. At other times, you’ll only want to perform operations for a given time range. For example, how many stock transactions have involved a particular company in the last 10 minutes? How many users have clicked to view a new advertisement in the last 15 minutes? An application may perform these operations many times, but the results may only be for a defined period or window of time.