Skip to content

Commit 5940213

Browse files
authored
feat: Enable auto-commit offsets as this is a demo (#22)
Signed-off-by: Katherine Stanley <[email protected]>
1 parent e0754b2 commit 5940213

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ Alternatively you can provide a custom path to the properties file using `-Dprop
4141
If your Kafka is secured you will need to enable the security configuration options in your properties file.
4242

4343
To increase the logging level to debug provide a system property at start time: `-Dlog.level=debug`.
44+
45+
To increase the Kafka client logging level to info provide a system property at start time: `-Dlog.level.kafka=info`.

kafka.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ bootstrap.servers=localhost:9092
77
###################################################################
88
group.id=my_group
99
auto.offset.reset=earliest
10-
enable.auto.commit=false
1110
key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
1211
value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
1312

src/main/java/kafka/vertx/demo/WebSocketServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.vertx.ext.web.handler.StaticHandler;
1818
import io.vertx.kafka.client.common.TopicPartition;
1919
import io.vertx.kafka.client.consumer.KafkaConsumer;
20+
import org.apache.kafka.clients.consumer.ConsumerConfig;
2021
import org.slf4j.Logger;
2122
import org.slf4j.LoggerFactory;
2223

@@ -44,6 +45,8 @@ public void start(Promise<Void> startPromise) {
4445
String propertiesPath = System.getProperty(Main.PROPERTIES_PATH_ENV_NAME, Main.DEFAULT_PROPERTIES_PATH);
4546
Main.loadKafkaConfig(vertx, propertiesPath)
4647
.compose(config -> {
48+
// Auto commit as this is a demo app
49+
config.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, true);
4750
kafkaConfig = config.mapTo(HashMap.class);
4851
return startWebSocket(router);
4952
})

src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<logger name="io.netty" level="warn"/>
1010
<logger name="io.vertx" level="info"/>
11-
<logger name="org.apache.kafka" level="error"/>
11+
<logger name="org.apache.kafka" level="${log.level.kafka:-error}"/>
1212
<logger name="org.apache.kafka.clients.NetworkClient" level="warn"/>
1313

1414
<root level="${log.level:-info}">

0 commit comments

Comments
 (0)