From the course: Complete Guide to Apache Kafka for Beginners
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Java consumer: Graceful shutdown - Kafka Tutorial
From the course: Complete Guide to Apache Kafka for Beginners
Java consumer: Graceful shutdown
Hi, this is Stephane from Conduktor and in this demo, we're going to add a shutdown hook to our consumer code. And this is going to allow us to just properly shut down the consumer just like we did previously, properly shut down the producer. Let's duplicate this consumer demo and I'll call this one consumer demo with shutdown. Okay. So we are done. We're going to keep the same Java application for now. We're going to keep the properties all the way. This is perfect and we're going to keep the consumer. But now we're going to actually, just before the subscribe creates what's called a shutdown hook. So the first thing we need to do is to get a reference to the main thread, the current thread. So what we do is that we do final thread main thread Equals thread.current thread. And this is a reference to the thread that is running my program. So this is the main thread because we are in the main method right now. So it's a reference because we'll be using it in a few seconds. and then we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Kafka SDK list1m 14s
-
(Locked)
Creating a Kafka project8m 37s
-
(Locked)
Java producer12m 4s
-
(Locked)
Java producer callbacks10m 9s
-
Java producer with keys4m 56s
-
(Locked)
Java consumer12m 15s
-
(Locked)
Java consumer: Graceful shutdown6m 49s
-
(Locked)
Java consumer inside consumer group4m 50s
-
(Locked)
Java consumer incremental cooperative rebalance and static group membership7m 13s
-
(Locked)
Java consumer incremental cooperative rebalance: Practice3m 56s
-
(Locked)
Java consumer auto offset commit behavior3m 1s
-
(Locked)
Programming: Advanced tutorials1m 36s
-
(Locked)
-
-
-
-
-
-
-
-