We have just created the producer using Python, and it took just three lines of code and we have sent
the message to big test and this topic was absent in our coffeecake last hour and it should have been
created automatically.
Let's verify that basically by creating a consumer in Python and connect to this topic and receive messages.
Let's go to our consumer file.
At the moment it is empty.
And let's start by importing Kalifa consumer from Kafka package from Kafka import Kafka consumer.
You could use autocomplete here.
And next, let's create consumer consumer equals sign Kafka consumer.
And here we need to specify a list of parameters.
And of course the topic name is mandatory and bootstrap sarus parameter is mandatory.
Let me explain that in several lines.
And the first topic name.
It is a test in our case.
And next, let's specify bootstrap sarus configuration parameter bootstrap underscore Saras and it is
equal to the same set of salaries that we have used here.
Let me put this away from here.
It go here and based and also let along with bootstrap Sarah's parameter, specify group ID parameter.
Let's do that on a separate line.
This parameter is called Group Underscore Edem and let's set it equal to, let's say, test consumer
group like Sole.
And now we are able to start consumption of the messages and we could do that in following way for message
in consumer.
Let's simply print this message, print message like so let's save this code and let's start our consumer
here.
And for that, I'll use again Python three.
And here, let's start consumer file.
It is running now, but we have not specified that we want to get messages from beginning.
That's why we need to rerun producer and send this message.
Let's open up new tab here and let's clear this terminal and the left and our bottom three producer,
Dot UI and our message was sent.
Let's go to Three-step, this one, and we should see that the message was received by consumer dot
UI.
It seems that the consumer does not get any messages and it seems that producer doesn't produce any
messages, probably.
This happens because the process finishes pretty quick and quicker than this message is sent.
Let me actually put here time and add the sleep timer import.
Time and here after this line, lets time sleep and let sleep, let's say 20 seconds, let's save this
cold.
Let's go to Deba with producer on it once again.
Notice that now it is still raining.
Let's go to consumer.
And yes, now we have received message.
And that was actually the reason why my producer was not able to send a message.
Broadcast was killed before this message was sent and now we have received message.
And actually next let's try to modify our producer and send more messages instead of just one.
I'll see you next.
Bye bye.