We have just successfully neutralized, you know, just project and now we are ready to proceed and
the let's first degrade producer that will produce Samatha just took off like last time.
And for that we could use the one of the public and the packages.
Let's find the suitable package.
Let's go to Google Chrome and let's type and Naude COFCO like this.
Let's open up FirstLine that will lead us to KAF Canoodled and package and second one with Scarfe Goodyear's
package.
Let me open up this one in a new tab and this one in a new type as well.
And let's compare those two packages here.
You'll see a weaker dollar account for this one Kafka note.
It is around seventy eight thousand times.
And you see the graph is constant here.
And if I go to Kafka, you'll see that with the dollar lost, count is around 48000.
But rent here is going up this way.
Let's first try this and the impact of the GST.
Let me scroll down.
And here below, you'll find out how to install this package.
You should use NPM, install command along with name, decent package.
And afterwards you should see a simple example on how to create producer and consumer.
Let's create our first producer based on this example.
And first, let's install Kafka gas package.
Let's go to terminal.
You could use ires or a separate terminal window, or you could use integrated terminal here directly
in the Beatles to the gold.
You could open it up by pressing the control and back.
DKK like this.
And actually, let me go ahead with this diamond window.
Let me hide this back pain and our terminal here and let's enter NPM, install Kafka, G.S., make sure
that you'll type a name on the package correctly, same as it is listed here and BMG dot com descarga
GS.
Let's go back to the escort and press.
Enter here.
Package now is loaded and no package was installed, if I go to package the desk on file.
You should see that there was additional dependency that was appeared here and that this package.
Wonderful.
Now we are ready to create our first producer.
Let me temporarily hide this terminal window, open up beside pain, and now let's create the new file
and let's create it in front of our project.
And let's name it simply.
Producer Dot goes like this.
And now in this file, we need to require a Kafka esque package and import from it Kafka Object.
And afterwards we will create a new instance of Kafka like that.
Let me actually copy this entire example and I'll copy it till the end.
And afterwards I'll remove parts related to consumer.
Let's go back to our project here, hide the side pain based, the carpet code.
And actually I don't need the consumer at the moment.
Let me remove this entire part.
And afterwards, lets us scroll up and modify Conexion details for our application, you may see here
array of brokers that we will connect to and actually we are in all brokers locally.
That's why here, let's use localhost everywhere.
And I'll add one more broker here.
Make sure that you'll change brought here to 1993.
And let me add the last broker in our class to localhost 1994.
Great.
All our brokers are here on the list.
And let's also modify client ID for our producer and let's name it my producer.
Like this, again, this will create a new instance of Kafka that is imported from Kafka G.S. model.
And afterwards we will create producer that is actually result of a call to producer method of the Kafka
Object.
And let me remove this line that we don't need consumer at the moment.
And the next there is a single function.
And here inside of this function, we will first wait for connection to our Kafka Kloster and afterwards
we will produce some messages to test Dobek.
And here was actually an array of messages that will be produced to Kafka, Gloster and actually let
me leave all those settings unchanged at the moment.
And afterwards we will change the topic name and produce more messages than just one.
Let's save this.
Let's open up and buy the terminal window clear terminal and let's try to start this producer and see
what will happen.
You could start at it simply by typing Nolde producer dogs I see here in the console that tells me that
there is no leader for this topic partition as we are in the middle of a leadership election.
Notice that we cannot agree that the topic called that topic ourselves.
But by default there was a setting that allows creation of the topic automatically.
And it seems that we we are not able to produce this one because the topic was just created and there
was no leader elected yet.
This way we could simply try to execute this code and see what will happen.
Let's terminate this process, control, see, and let's rerun our producer, not producer dogs.
And now we don't see any errors.
But on the other side, we also don't see any meaningful logs here in the console.
But it seems that our message was produced successfully.
Let's verify that.
Let's close this producer.
Stop it actually.
And let's now start the console consumer and verify whether there was this one in test today.
Let's go to our list of commands here with this and let's start the console consumer.
Let me scroll to the very end of this file and let me replace Tropicals with their stivic like this.
And let's read messages from beginning.
Let me copy a..
Commander, go to Diamond Knoll here.
Let's clear terminal and let me actually Sidis to Kafka for that are located in a user directory because
now I am in a folder, Kafka, located on the desktop, Leaside and Sedita, Kafka and Paste copied
command like this and read messages from desktop.
And now I see two messages, and that means that actually after the start of our application message
was finally produced after this error this way here I see the same messages.
Hello, Kafka, Jesusa.
And that means that our producer was able to successfully produce messages.
And next, let's adjust it a bit and let's produce more messages.
Let's say one hundred messages, same as in our example.
And each message will have a different value.
I'll see you in the next lecture.
Bye bye.