All right.
So there are a couple of more aspects of the Ad Men API that you can use to manage the contents of your
Kafka topics, as well as how they're configured that I wanted to at least make sure that you all get
exposure to.
So some of the stuff might not make sense yet because we haven't maybe covered the underlying theoretical
aspects of what this is doing so far, but they will come in handy down the road.
And since this is the admin section, let's, let's make sure we at least take a look at them and then
you can refer back to them when things clear up.
And so the first thing I want to highlight is you can change the retention value of how long Kafka will
hold on to messages, and that's on a per topic level that you can set this when you're creating a topic.
You can also set this on a per broker level when you install your own version, when you install your
own Kafka installation.
However, we will not be covering the myriad of different complexities that come into deploying your
own Kafka environment.
I highly recommend using managed services like Confluent or, you know, maybe like A.W. -- managed
streaming, Kafka service.
Those are both excellent choices for real live production systems.
I do not recommend deploying your own Kafka.
However, you are going to want to be able to administer it and work with it.
So that's what we're going to cover here.
And so you can create Kafka topics.
We saw that earlier on in the last lecture, but you can also alter the retention period.
So the default retention period for just a base install of Kafka is two weeks.
You know, sometimes most of the time you're going to want to set that to a larger value and other times
you're going to want to set them to a smaller value.
To do that, you'll use a command like this.
Kafka Topics Create Bootstrap Server the name of your topic, and then you'll add a config flag with
the the name and value of a config that you want to change.
And in the case of altering the or making a topic with a different non default retention value, you
just say retention times for milliseconds and then you specify the number and milliseconds representative
of how long you want the messages in your Kafka topic to hang out for.
So let's create an experiment topic that has a retention period of one hour.
So if you do 60 minutes times, 60 seconds time 1000, you'll get 360,000.
So we'll go ahead and do a Docker exec.
Well, let's first make sure everything's running once you compose.
Yes.
All right.
We can see everything is up and healthy.
So I want to interact with the CI tools container so I will do a Dr. exac dash i.t selah tools and then
Kafka topics and then huge trap server broker zero 20 9092 and we'll do a create and then a topic and
we're going to x be romance experiments like that and then we'll pass in the config value again of retention.
RMS We'll set that equal to 360.
Thousand.
Okay.
So that now created my experiments topic and set a non default retention period.
We can look that up by using the describe all described all for the Kafka configs.
See what we haven't seen the Kafka config select tool yet, but it's very similar to the Kafka topics
CAA tool.
So let's go ahead and try that one out.
So we'll just up arrow.
So I don't have to type quite as much.
And then we'll set this part not to create, but to just grind.
And then all.
And then we'll come back here to the actual name of the SEAL program to be ran instead of topics is
can fix.
And we can see this dumps out all of the different configs for this particular topic.
And if we look real close and scan down here, we can see that retention milliseconds has been set to
what we set it to, 360,000 milliseconds or one hour.
All right.
So what if we wanted to change a topic that already existed, right?
So you use the Kafka configs, um, Seelye tool for that as well.
However, instead of describe your set it to alter and then you need to specify the entity type, which
is topics the name of the entity, which is the topic name of experiments.
And then you say add config and you change it to something else so it won't go back up again and will
get rid of all this and we'll do.
Alter And then what were the other parts?
Right there.
So alter and then the entity type are topics, the entity name is experiments and then we add config,
which is a little bit of a confusing way to say it, but that is how the API works to, let's say 500,000.
So a little more.
And if I scan through and make sure I didn't make any mistake, it looks like I've written that out
correctly.
So I go ahead and execute that.
Um, oop.
And I did mess up here.
I need to say re tension amps.
They're not just.
Config.
So now if I up arrow a couple more times and we now describe this topic once again using the Kafka config
seal tool, we should see that that retention milicic value has been updated to 500,000 and it has been.
So that's how you will that's how you can use the CGI tools to alter different things with your, you
know, with how you create your topics.
There's probably one more that I want to show you how to create a compacted topic.
We're going to spend some time talking about compacted topics later on in this course, but let's go
ahead and just give a quick demo on how to create a compacted topic.
So I will do a Docker exec dash i.t Seelye Tools Kafka topics is the sealer tool and then bootstrap
server of Broker zero on Port 29 zero 92.
We're going to create a topic in that topic is going to be named X Bereavements Latest and then we're
going to do config and we're going to say clean up period policy equals compact and this will create
this a compacted topic except for it looks like I forgot to give the name of this topic.
So let me URL and I'll fill in the topic flag and then it will know what to do.
So topic.
All right.
And it gives me a warning.
You know, it tells you not to use underscores and periods.
However, they're widely prevalent in industry.
So don't worry too much about that.
But let's go ahead and describe the configs for this now.
Actually, let's just describe.
Experian in its latest.
I believe this one will actually just come up for the Kafka topics.
SEELYE And there's not quite so much information to read through.
All right.
So there we can see the cleanup policy has been set to compact.
So it makes it a compact, a topic which we will review what that means and detail later.
But you can come back to this lecture if you want to make come back to topics later after we figure
out what those are.
All right.
So thanks for joining with me in this lecture.
And we got it useful.
Like I said, if it doesn't make sense quite yet, don't worry.
You will undoubtedly refer back to this lecture and use those commands throughout your year, of course,
of being a Kafka software engineer.
Thank you for joining.