WEBVTT 00:04.770 --> 00:09.980 We have just successfully neutralized, you know, just project and now we are ready to proceed and 00:09.980 --> 00:14.930 the let's first degrade producer that will produce Samatha just took off like last time. 00:15.210 --> 00:19.040 And for that we could use the one of the public and the packages. 00:19.410 --> 00:21.180 Let's find the suitable package. 00:21.190 --> 00:28.080 Let's go to Google Chrome and let's type and Naude COFCO like this. 00:29.130 --> 00:36.020 Let's open up FirstLine that will lead us to KAF Canoodled and package and second one with Scarfe Goodyear's 00:36.030 --> 00:36.440 package. 00:36.690 --> 00:40.800 Let me open up this one in a new tab and this one in a new type as well. 00:41.070 --> 00:43.290 And let's compare those two packages here. 00:43.290 --> 00:46.350 You'll see a weaker dollar account for this one Kafka note. 00:46.350 --> 00:49.290 It is around seventy eight thousand times. 00:49.290 --> 00:52.120 And you see the graph is constant here. 00:52.320 --> 00:57.450 And if I go to Kafka, you'll see that with the dollar lost, count is around 48000. 00:57.450 --> 01:00.010 But rent here is going up this way. 01:00.030 --> 01:03.980 Let's first try this and the impact of the GST. 01:04.260 --> 01:05.370 Let me scroll down. 01:05.370 --> 01:08.980 And here below, you'll find out how to install this package. 01:08.980 --> 01:13.110 You should use NPM, install command along with name, decent package. 01:13.320 --> 01:18.980 And afterwards you should see a simple example on how to create producer and consumer. 01:19.380 --> 01:22.320 Let's create our first producer based on this example. 01:22.320 --> 01:25.580 And first, let's install Kafka gas package. 01:25.920 --> 01:27.330 Let's go to terminal. 01:27.450 --> 01:33.210 You could use ires or a separate terminal window, or you could use integrated terminal here directly 01:33.210 --> 01:34.470 in the Beatles to the gold. 01:34.470 --> 01:37.530 You could open it up by pressing the control and back. 01:37.530 --> 01:38.730 DKK like this. 01:38.910 --> 01:41.760 And actually, let me go ahead with this diamond window. 01:42.060 --> 01:50.790 Let me hide this back pain and our terminal here and let's enter NPM, install Kafka, G.S., make sure 01:50.790 --> 01:57.320 that you'll type a name on the package correctly, same as it is listed here and BMG dot com descarga 01:57.390 --> 01:57.990 GS. 01:58.050 --> 02:00.210 Let's go back to the escort and press. 02:00.210 --> 02:01.020 Enter here. 02:02.290 --> 02:08.590 Package now is loaded and no package was installed, if I go to package the desk on file. 02:08.620 --> 02:15.140 You should see that there was additional dependency that was appeared here and that this package. 02:15.520 --> 02:16.100 Wonderful. 02:16.310 --> 02:18.670 Now we are ready to create our first producer. 02:18.700 --> 02:26.500 Let me temporarily hide this terminal window, open up beside pain, and now let's create the new file 02:26.620 --> 02:29.200 and let's create it in front of our project. 02:29.200 --> 02:30.610 And let's name it simply. 02:30.610 --> 02:34.180 Producer Dot goes like this. 02:34.390 --> 02:40.860 And now in this file, we need to require a Kafka esque package and import from it Kafka Object. 02:41.140 --> 02:44.550 And afterwards we will create a new instance of Kafka like that. 02:44.830 --> 02:51.040 Let me actually copy this entire example and I'll copy it till the end. 02:51.220 --> 02:54.460 And afterwards I'll remove parts related to consumer. 02:54.730 --> 03:00.880 Let's go back to our project here, hide the side pain based, the carpet code. 03:00.880 --> 03:04.420 And actually I don't need the consumer at the moment. 03:04.630 --> 03:07.300 Let me remove this entire part. 03:08.980 --> 03:15.340 And afterwards, lets us scroll up and modify Conexion details for our application, you may see here 03:15.370 --> 03:21.500 array of brokers that we will connect to and actually we are in all brokers locally. 03:21.520 --> 03:24.630 That's why here, let's use localhost everywhere. 03:25.000 --> 03:27.770 And I'll add one more broker here. 03:27.910 --> 03:31.930 Make sure that you'll change brought here to 1993. 03:32.240 --> 03:37.750 And let me add the last broker in our class to localhost 1994. 03:38.020 --> 03:38.470 Great. 03:38.710 --> 03:40.660 All our brokers are here on the list. 03:40.660 --> 03:47.350 And let's also modify client ID for our producer and let's name it my producer. 03:48.920 --> 03:56.500 Like this, again, this will create a new instance of Kafka that is imported from Kafka G.S. model. 03:56.720 --> 04:03.860 And afterwards we will create producer that is actually result of a call to producer method of the Kafka 04:03.860 --> 04:04.370 Object. 04:04.520 --> 04:08.240 And let me remove this line that we don't need consumer at the moment. 04:08.430 --> 04:11.780 And the next there is a single function. 04:11.780 --> 04:18.140 And here inside of this function, we will first wait for connection to our Kafka Kloster and afterwards 04:18.140 --> 04:21.080 we will produce some messages to test Dobek. 04:21.230 --> 04:27.800 And here was actually an array of messages that will be produced to Kafka, Gloster and actually let 04:27.800 --> 04:31.300 me leave all those settings unchanged at the moment. 04:31.310 --> 04:36.520 And afterwards we will change the topic name and produce more messages than just one. 04:36.890 --> 04:38.120 Let's save this. 04:38.630 --> 04:46.130 Let's open up and buy the terminal window clear terminal and let's try to start this producer and see 04:46.130 --> 04:47.010 what will happen. 04:47.240 --> 04:55.160 You could start at it simply by typing Nolde producer dogs I see here in the console that tells me that 04:55.220 --> 05:00.330 there is no leader for this topic partition as we are in the middle of a leadership election. 05:00.650 --> 05:05.690 Notice that we cannot agree that the topic called that topic ourselves. 05:05.840 --> 05:10.430 But by default there was a setting that allows creation of the topic automatically. 05:10.580 --> 05:17.270 And it seems that we we are not able to produce this one because the topic was just created and there 05:17.270 --> 05:19.080 was no leader elected yet. 05:19.320 --> 05:23.930 This way we could simply try to execute this code and see what will happen. 05:24.020 --> 05:30.800 Let's terminate this process, control, see, and let's rerun our producer, not producer dogs. 05:31.160 --> 05:32.810 And now we don't see any errors. 05:32.810 --> 05:37.580 But on the other side, we also don't see any meaningful logs here in the console. 05:37.820 --> 05:40.920 But it seems that our message was produced successfully. 05:41.120 --> 05:42.070 Let's verify that. 05:42.290 --> 05:44.300 Let's close this producer. 05:44.300 --> 05:45.290 Stop it actually. 05:45.470 --> 05:52.990 And let's now start the console consumer and verify whether there was this one in test today. 05:53.360 --> 05:59.180 Let's go to our list of commands here with this and let's start the console consumer. 05:59.450 --> 06:06.710 Let me scroll to the very end of this file and let me replace Tropicals with their stivic like this. 06:07.850 --> 06:09.890 And let's read messages from beginning. 06:10.190 --> 06:11.280 Let me copy a.. 06:11.340 --> 06:14.140 Commander, go to Diamond Knoll here. 06:14.390 --> 06:21.200 Let's clear terminal and let me actually Sidis to Kafka for that are located in a user directory because 06:21.200 --> 06:28.370 now I am in a folder, Kafka, located on the desktop, Leaside and Sedita, Kafka and Paste copied 06:28.370 --> 06:31.130 command like this and read messages from desktop. 06:32.320 --> 06:38.650 And now I see two messages, and that means that actually after the start of our application message 06:38.650 --> 06:44.260 was finally produced after this error this way here I see the same messages. 06:44.270 --> 06:45.900 Hello, Kafka, Jesusa. 06:46.240 --> 06:50.520 And that means that our producer was able to successfully produce messages. 06:50.530 --> 06:54.330 And next, let's adjust it a bit and let's produce more messages. 06:54.340 --> 06:57.520 Let's say one hundred messages, same as in our example. 06:57.640 --> 07:00.310 And each message will have a different value. 07:00.580 --> 07:02.020 I'll see you in the next lecture. 07:02.050 --> 07:02.470 Bye bye.