We have just successfully created a producer and the consumer in Python, and we have received the basically
message by consumer here is this consumer record and we have sent actually only a single message by
a producer.
And here the contents of the message here was it's Bellear key was set to.
And that's why here you see this as well.
You see also topic name.
This message was read from partition.
It is a partition with 80 zero of said of this message inside of this partition timestamp and other
related information about this going through my record.
Now, let's expand a bit to this example.
And instead of just a single message, let's send the 100 random names and let's send them to a topic
called names.
Let's modify this producer.
And here we will import to Fakher from Fakher package.
But first of all, we need to install it.
Let me show you what actually this package does.
Let's enter.
Facher Python.
And CrossLink should lead us to this package.
Yes, here it is, you could actually fake different addresses, names or texts using this package.
Let me scroll down a bit.
And here you see examples of how you are able to fake different names.
Let's install a fake or using a good paper using a package manager for Python and let me do that in
this embedded terminal and let me open up a new terminal here.
Let me clear it and I'll install it.
Used to be a three for Python three.
So be a B three.
Install Fraker, Antawn, let me enter my password.
Notice that with such command and installation, quake are globally, same as we did with a Kafka client,
it seems that the now Fakher was successfully installed here.
I sent this message and now I'm able to close this terminal window and use failure here.
Let's import from fake or import fake like this.
And afterwards, let's create a new instance of fake like so fake equals sign fake.
And now we're able to use the different methods of fake.
Let me here create a loop that will actually produce 100 messages and we will send 100 messages with
different names.
Let me create a loop of four underscore in range, let's say, 100 messages.
You could send more if you want and here will produce.
Let me move it here and I'll send the two topic names, messages like let me remove this and here will
be called the fake dot name and where or parentheses.
Of course, we need to convert to this result to bite format.
And for that you could use encode method.
And here, because actually we can call the strings window, specify encoding and it is UTF eight for
text.
That's actually all.
And let's basically create here variable and assign this result to this variable.
And afterwards we will also bring to the console this variable in order to ensure that the producer
has actually sent messages.
Let me do that like so name and here will be name and code to buy it.
And also let's bring to the console print name.
Like, so this should work now, let's save the gold to open up time terminal and let's produce those
messages.
Let me go to the tap where we have started produce our heroes staff and restarted once again.
And yes, it seems that the messages were produced and we see here different names that were generated
by Fakher package.
Let's now go to consumer.
It seems that it should still be running and we need to stop it because we have actually read messages
from another topic, from our topic, and we need to read messages now from names.
Stop.
Let me replace a test with names.
And here, let's say consumer group idea will be it now names like So let's save and let's roll around
consumer buy them three consumer Dobi.
And of course, we need to restart producer and generate 100 messages, because now we are reading from
our current position in our politicians.
Let me go to producer and run it clear terminal and start producer.
Again, one hundred names were generated.
Let's now go to consumer, and now I see how messages are received from two big names.
And you see here that partition is the same here because in this case, two big names was again created
automatically, same as the topic text.
And when topic is created automatically by default, it gets just a single partition.
That's why here we see everywhere partition with ID zero.
But of says, of course, a different each message has unique offset inside of this partition.
And as you see here, we successfully received different names and we are able to read them by a consumer
like Emily Davidson, Jennifer Alem and so on.
That's how we able pretty fast and easily great consumer and the producer in Python.
And here I have demonstrated you just the simple example of how we are able to create different names,
fake names and send them in separate messages.
This all goes for this example and is usually project files will be available in GitHub repository by
by.