We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a04a0c1 commit 4d7088cCopy full SHA for 4d7088c
apache-kafka-3/src/main/java/com/baeldung/kafka/KafkaAddPartitionExample.java
@@ -0,0 +1,23 @@
1
+package com.baeldung.kafka;
2
+
3
+import java.util.Collections;
4
+import java.util.Properties;
5
6
+import org.apache.kafka.clients.admin.AdminClient;
7
+import org.apache.kafka.clients.admin.NewPartitions;
8
9
+public class KafkaAddPartitionExample {
10
11
+ public static void main(String[] args) {
12
+ Properties props = new Properties();
13
+ props.put("bootstrap.servers", "localhost:9092");
14
+ try (AdminClient adminClient = AdminClient.create(props)) {
15
+ adminClient.createPartitions(Collections.singletonMap("my-topic", NewPartitions.increaseTo(3)))
16
+ .all()
17
+ .get();
18
+ } catch (Exception e) {
19
+ throw new RuntimeException(e);
20
+ }
21
22
23
+}
0 commit comments