In the previous examples in this section, we have agreed that producers that can produce must adjust
to any topic and we have agreed that topic numbers for that.
And this producer produces 100 messages.
And in the configuration of this topic, we have specified that we want to have five different partitions.
And basically we have seen that all managers are spread across the partitions from zero to I.D. form.
Also, we have agreed that to several consumers like consumer was out to commit, consumer was may not
commit and consumer with protections assignment.
And in the last example, we have assigned consumer only to several partitions.
But now in this example, let me demonstrate you how we are able to launch multiple instances of the
same consumer, and that will mean that we will have multiple consumers that will belong to the same
consumer group.
If I open, for example, this file consumer was able to commit, you'll see that we have specified
that those settings put the group ID through the group.
That means that this is the consumer when to start.
It will belong to consumer group called Thralls Group.
Basically, we have specified the group in area of those consumers and if you'll open this one here,
you'll see a second group and if you'll open up.
But this consumer with protections assignment, you'll find the third group here as well.
But in this example, let's reduce the consumer that we have agreed to before this one consumer was
out to commit.
But in order to be able to start multiple instances of the same consumer, of the same process, actually,
you need to to modify settings.
You need to go here, click edit configurations and select here consumer with without to commit this
one.
And afterwards check this checkbox alow borrow from this one.
And after checking this box, you need to click, apply and locate.
Please note is that if you don't see consumer was able to commit here, you need to start this consumer
at least once.
Just a click here and select the one main method of the consumer without a computer class.
And basically let's now start to our thralls, the consumer that will belong to thralls group.
And let's click here.
Run like this.
Consumer is running now let's start one more instance of the same consumer and same as before.
Click here.
And Ron, main method of this class and notice that this process will be started in a separate app.
And now we have two different consumers up and running.
And no, it's a good time to start our producer and produce just two topic numbers.
Let's go to producer and let's run its main method.
Producer has successfully sent 100 messages, and now let's go to the consumer and verify which messages
it has received.
And in my case, I see that this consumer has received messages from Patison with a form and partition
with Idear three.
And if I grow up, I will not see any of the partitions.
And that means that this consumer was allocated only two partitions partition beside three and partition
with a default.
If I go to second, tap this one and observe which messages this consumer has received, I'll see that
it has actually got messages from all remaining partitions here.
I see partition with ID one.
Next I will see partition with added to and I also should see partition with a zero.
And if it is the case and that means that our Kafka cluster has allocated three partitions to this consumer
and the two partitions were allocated to this consumer in order to find out which partitions were assigned
to different consumers, we need to use a command that will give us details about specific consumer
group.
And in our case, we have used the consumer group with name first group in order to quickly find this
command and reuse.
It does go to our GitHub repository, go to examples folder and select example consumer groups and let's
open up this text file with all related commands.
And the here somewhere at the end will be command that will lead to the tales of specific consumer group.
And here we need to replace this group name with name in our case for the group.
Let me copy.
Throws the group from here and replace Namath's with Ferrol, the group.
Let's leave here single Sara.
Copy this entire command, open up a terminal window and here ensure that you are in a folder based
command and presenter.
And here, I'll see how different the partitions were assigned to different consumers, and in our case
at the moment, we are run in two different consumers.
Here they are.
And I should see two different the consumer IDs here in the least.
And here I see first consumer ID is assigned to partition zero and the same consumer is assigned to
partition with ID one and with ID to hear is.
Please notice that in your case, assignments will be completely different and to remain in the partitions,
partitions with ID three and ID four assigned to another consumer with such ID.
That's how partitions will spread across the two different consumers that are currently running in our
setup.
Let's not default.
Let's start one more instance of the consumer.
Same consumer with all the commit in the same consumer group therapist group.
Let's click here again Romdhane method.
It will be started in a new tab and now I have three different consumers up and running.
And now let's go back to terminal and execute this previous command.
Described by the group, a consumer group, and now I should see three different consumers on the list.
And this is the case.
This consumer is now assigned just to two different positions with least two and three.
This consumer was assigned to partitions with zero and one, and new consumer was assigned to Patison
with a default.
And that's completely fair.
All participants were equally spread across three different consumers to two and one.
Patison Wonderful.
Let's now go back to our project here and the stuff the producer once again, Ron, it's the main method.
And we should see that this last consumer will get the messages only from a single Patison.
Again, in my case, it was assigned only to partition with ID for here I see this in output in time
and the same information I see here in this output.
Wonderful.
That's how you're able to create different consumers in the same group and delonge them in parallel
if you want.
You could experiment and delonge your two more copies of those consumers and verify that each of them
will get just a single partition.
And afterwards you could try to start one more consumer.
It will be six consumer and you'll see that inside the top one of the consumers will be idle and will
be assigned any partitions at all.
That's all for this example.
And next, you'll get short challenge for you.
See you next.
Bye bye.