This recipe will combine a Kafka consumer with a Goflow pipeline. As our consumer receives messages from Kafka, it will run strings.ToUpper() on them and then print the results. These naturally pair, as Goflow is designed to operate on an incoming stream, which is exactly what Kafka provides us.
Getting ready
Refer to the Getting ready section ofthe Using Kafka with Sarama recipe.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter12/kafkaflowand navigate to this directory.
- Run this command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter12/kafkaflow
You should see a file calledgo.modthat contains the following:
module github.com/PacktPublishing/Go-Programming-Cookbook...