From: Kai Moritz Date: Sat, 14 Oct 2023 12:44:23 +0000 (+0200) Subject: Topic konfigurierbar gemacht X-Git-Tag: spring/endless-producer-DEPRECATED~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=91ecfd4f5f2297096b4057ed24135053cbafcc55;p=demos%2Fkafka%2Ftraining Topic konfigurierbar gemacht --- diff --git a/README.sh b/README.sh index 1b1e5ae..c39fe5b 100755 --- a/README.sh +++ b/README.sh @@ -10,7 +10,6 @@ then fi docker-compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3 -docker-compose -f docker/docker-compose.yml rm -svf consumer if [[ $(docker image ls -q $IMAGE) == "" || @@ -28,7 +27,7 @@ docker-compose -f docker/docker-compose.yml run --rm cli cub kafka-ready -b kafk docker-compose -f docker/docker-compose.yml up -t0 -d cli docker-compose -f docker/docker-compose.yml ps -docker-compose -f docker/docker-compose.yml up -d producer +docker-compose -f docker/docker-compose.yml up producer # tag::kafkacat[] kafkacat -b :9092 -t test -e -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 7b436cd..e85482d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -104,3 +104,4 @@ services: environment: spring.kafka.bootstrap-servers: kafka:9092 spring.kafka.client-id: producer + spring.kafka.template.default-topic: test diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index 7a23da9..5e123dd 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -28,7 +28,7 @@ public class Application implements ApplicationRunner // tag::callback[] ListenableFuture> listenableFuture = // tag::supersimple[] - kafkaTemplate.send("test", Long.toString(i%10), Long.toString(i)); + kafkaTemplate.sendDefault(Long.toString(i%10), Long.toString(i)); // end::supersimple[] listenableFuture.addCallback( diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8d1d298..51cc46c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,5 @@ spring: kafka: bootstrap-servers: :9092 + template: + default-topic: test