How it works...
In this recipe, we demonstrated how to create a streaming application that listens for TCP connections. Tcp.bind() is responsible for creating the listener in the given hostname and port. In this case, the stream does not have a Sink explicitly defined. This is because we are using the helper method runForeach, which is an alias of Sink.foreach.
It is good to mention that each connection is a Flow that represents a real incoming connection, and it can be materialized only once. That's why this Flow cannot be reused as other Flows can. We used the handleWith method to provide a word count. This wordCount flow ingests the incoming messages from the TCP connection and returns the element emitted by the last transformation. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access