WEBVTT 00:04.450 --> 00:09.460 OK, let's go one was configuration of the consumer and actually let me first create the track edge 00:09.460 --> 00:15.250 blocker, here will be a dry block, then get here will be exception. 00:17.150 --> 00:22.510 And here, if something went wrong, let's bring this exception e bring the stack trace like this. 00:22.520 --> 00:28.790 And finally, same as always, producer, we need actually to close consumer consumer, not close like 00:28.790 --> 00:29.030 that. 00:29.390 --> 00:29.960 Wonderful. 00:30.200 --> 00:31.530 And the here in a drive. 00:31.550 --> 00:34.790 Look, let's add the infinite loop like in this example. 00:35.000 --> 00:39.560 Actually, let me copy it quickly from here and the place to our project like that. 00:39.560 --> 00:44.540 And after you have pasted the section, you'll see that those glasses are highlighted in red and that 00:44.540 --> 00:46.940 means that they are not important automatically. 00:47.120 --> 00:53.050 And in order to input, each of them are simply hover miles over specific glass and the glass. 00:53.330 --> 00:55.530 This consumer, because glass was important. 00:55.760 --> 00:57.920 Same way you should do with durational glass. 00:57.920 --> 01:01.210 It will be imported from Java Time, less important as well. 01:01.220 --> 01:07.070 And let's also import consumer record glass, import glass, if you will scroll up, you'll see all 01:07.070 --> 01:09.440 of those imports here at the beginning of the file. 01:09.590 --> 01:14.900 And actually we're able to reduce the size of those imports and simply instead of three records here, 01:15.050 --> 01:17.060 import everything from consumer. 01:17.060 --> 01:23.760 And the here will simply start out like this wildcard import and saying we could do with Java or deal 01:23.870 --> 01:29.530 imports or remove this one and simply replace here with stuff like that. 01:29.870 --> 01:30.220 Great. 01:30.470 --> 01:32.600 Let's go back to our infinite loop. 01:32.600 --> 01:34.700 Notice that here we use condition. 01:34.700 --> 01:35.060 True. 01:35.180 --> 01:40.030 And this means that this whale will be running until you manually exit from the programme. 01:40.460 --> 01:44.720 Let me actually quickly refactor it to and first, let me explain to you what happens here. 01:45.140 --> 01:52.330 Every one hundred milliseconds we pull brockers and we get new records, if any. 01:52.550 --> 01:56.390 And if there are some records, we loop over those records. 01:56.390 --> 02:00.650 And afterwards you could perform any actions with the records you want. 02:00.770 --> 02:07.550 And in this example, parts of each record, like of said the key and velia formatted and the printed 02:07.550 --> 02:08.330 to terminal. 02:08.510 --> 02:15.440 And as you'll see, each record has such Mathilde's as offset the key value and looking actually at 02:15.440 --> 02:21.830 his block of statements like this and the inside of it, the lethargically on your variable message, 02:22.070 --> 02:28.730 string message and live here use format, method of the string string format. 02:29.400 --> 02:37.730 And here, let me simply copy antiapartheid here, indorse parentheses like this and paste here and 02:37.730 --> 02:44.870 afterwards let's simply use a studio and print message to Tamina like this and I don't need this line 02:44.870 --> 02:45.390 anymore. 02:45.650 --> 02:46.100 Great. 02:46.220 --> 02:50.900 That's actually all what we need in order to get some meaningful output from this first consumer. 02:51.050 --> 02:53.420 And let's actually try to start it. 02:53.570 --> 02:56.330 Let's start the main method of the consumer class. 02:56.600 --> 02:57.350 Let's run it. 02:59.490 --> 03:06.630 And it seems I got an error unable to commit to cannot be such a wonderful group I.D. now is used and 03:06.630 --> 03:13.150 that means that we are actually not able to use our to commit without customer consumer group I.D.. 03:13.410 --> 03:21.930 Let's actually fix that unless specified group ID here, broad support group ID and let's make it equal, 03:21.930 --> 03:24.630 for example, to a group like that. 03:24.840 --> 03:25.830 And now it should work. 03:26.100 --> 03:29.970 Let me expand this window and let's aronne consumer. 03:31.910 --> 03:38.690 And it seems that now consumer was successfully started and now it polls for Numata just every 100 milliseconds, 03:38.930 --> 03:44.330 and if you scroll up to the beginning of this output, you'll see a set of parameters that were used 03:44.360 --> 03:45.890 for the start of this consumer. 03:46.040 --> 03:51.170 And for example, here you see array of bootstrap scenarios that we have set up here on this line. 03:51.440 --> 03:58.880 Also, you see all the comet intervale also enable our to option is set to drop and the group ID is 03:58.880 --> 04:00.450 set to first group. 04:00.930 --> 04:01.310 Great. 04:01.520 --> 04:07.940 Let's not actually start our producer and let's produce some messages to no storbeck because here we 04:07.940 --> 04:10.010 have subscribed to no Storbeck. 04:10.280 --> 04:11.640 Let's go to producer. 04:11.900 --> 04:19.430 Make sure to change your topic name to numbers and let's uncommented our first example, this one like 04:19.430 --> 04:19.760 this. 04:20.000 --> 04:26.930 For that, you need to press a command and forwards and let's comment all this example to like this 04:27.200 --> 04:29.120 and let's start our producer. 04:29.120 --> 04:31.160 Let's run my method here. 04:33.460 --> 04:39.820 It will be started in separate type like this, and you'll see that 100 messages were sent and afterwards 04:40.030 --> 04:41.600 producer has exited. 04:41.860 --> 04:42.970 Let's go to consumer. 04:42.970 --> 04:50.020 And yes, so we see here actually 100 messages that were just consumed and each message was formatted 04:50.020 --> 04:56.260 like we specify it here on this line and we see here offset set for each record. 04:56.920 --> 05:00.370 And, well, we used here three methods of the record. 05:00.490 --> 05:08.320 And you'll see, for example, that this message got offset number 106 and Eskil was 65 and Waialua 05:08.320 --> 05:09.960 is also equal to 65. 05:10.150 --> 05:14.980 And actually, let's modify this to and let's also add information about partition. 05:15.160 --> 05:21.250 And for that, you could use a record dot partition method that's add it here at the end, a record 05:21.640 --> 05:23.770 dot partition like this. 05:24.220 --> 05:30.790 And it will add information about partition and lengths also included here in Vermont and here, let's 05:30.790 --> 05:39.460 type partition equal sine percentage sine s it will be between and let's restart our consumer and afterwards 05:39.490 --> 05:42.750 let's produce one more hundred messages by producer. 05:43.180 --> 05:47.620 For that, let's go to consumer and the press on this button that will run consumer. 05:50.260 --> 05:52.600 It was restarted and now it is waiting for messages. 05:52.810 --> 05:56.140 Let's go to producer Deb and let's start at over. 05:57.980 --> 05:59.650 OK, messages well sent. 05:59.810 --> 06:06.800 Let's go back to consumer and now we see all this information about partition of said well and partition, 06:07.100 --> 06:14.060 but it seems that I have screwed up with formatting and I need to move a line break character from this 06:14.060 --> 06:19.370 place to the end of the formatted screen and left or around consumer once again. 06:22.380 --> 06:24.950 And let's talk producer once again as well. 06:26.000 --> 06:27.230 Let's go back to consumer. 06:28.290 --> 06:34.710 And now we see nicely four messages, and each of them contains information about offset key value and 06:34.710 --> 06:39.980 partition, that our topic numbers was created with five partitions. 06:40.230 --> 06:44.070 Let me go to our configuration of the topic, and here it is. 06:44.220 --> 06:46.590 Here is how we agreed that the topic swings. 06:46.590 --> 06:50.010 But in the same way, we have agreed that topic numbers. 06:50.190 --> 06:55.800 And if you'll go here, you'll see that the messages were spread across different partitions. 06:55.800 --> 06:59.470 For example, here you'll see a partition number two here with partition number three. 06:59.820 --> 07:06.060 Next, if your school appeals information from other partitions and notice that the consumer actually 07:06.060 --> 07:08.500 has consumed messages in batches. 07:08.520 --> 07:12.260 It means that it has received a set of messages from each partition. 07:12.270 --> 07:17.900 And here in the output, you clearly see that order of the messages is different from the order. 07:17.940 --> 07:20.170 How they were produced by a producer. 07:20.580 --> 07:25.080 Is because, again, they were produced to different partitions and they were consumed from different 07:25.080 --> 07:25.800 partitions. 07:26.250 --> 07:31.440 But if you have a look at the messages that were consumed from a specific partition, for example, 07:31.440 --> 07:38.430 from partition with a one, you'll see that of sets of all those messages arranged by offset. 07:38.430 --> 07:45.620 No, that's because all messages in each partition are stored one by one with in command of sets. 07:45.660 --> 07:48.230 And here you clearly see that wonderful. 07:48.420 --> 07:54.210 That's all for this first example where we have actually connected to the cluster of brokers and the 07:54.210 --> 07:59.130 where we have received information from the topic numbers we haven't figured out to commit. 07:59.130 --> 08:00.900 And all the commitments are just us. 08:00.900 --> 08:05.820 And every second and also we have configurator, consumer group, Edem. 08:06.240 --> 08:06.650 Great. 08:06.840 --> 08:08.070 That's all for this example. 08:08.080 --> 08:14.640 And next to let me go back to documentation and let me quickly make an overview of most important parameters 08:14.640 --> 08:17.970 that you could set up at a consumer level. 08:18.060 --> 08:20.610 And for that, let's go to the recommendation. 08:21.650 --> 08:28.700 Here, scroll down and let's choose consumer to fix this section and let me make a quick overview of 08:28.700 --> 08:31.130 most important parameters next by by.