fi
docker-compose up -d kafka-1 kafka-2 kafka-3 cli
-docker-compose rm -svf producer
+docker-compose rm -svf acks-all acks-1 acks-0
if [[
$(docker image ls -q $IMAGE) == "" ||
fi
docker-compose up setup
-docker-compose up producer
-
-docker-compose exec cli kafkacat -b kafka:9092 -t test -q -e -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n'
+docker-compose up -d acks-all acks-1
+sleep 5
+docker-compose stop kafka-1
+sleep 5
+docker-compose stop kafka-3
+sleep 5
+docker-compose stop acks-all acks-1
+docker-compose logs acks-all acks-1
image: juplo/toolbox
command: sleep infinity
- producer:
+ acks-all:
image: juplo/supersimple-producer:1.0-SNAPSHOT
environment:
spring.kafka.bootstrap-servers: kafka:9092
- spring.kafka.client-id: producer
+ spring.kafka.client-id: acks-all
+ spring.kafka.producer.acks: all
+
+ acks-1:
+ image: juplo/supersimple-producer:1.0-SNAPSHOT
+ environment:
+ spring.kafka.bootstrap-servers: kafka:9092
+ spring.kafka.client-id: acks-1
+ spring.kafka.producer.acks: 1
+
+ acks-0:
+ image: juplo/supersimple-producer:1.0-SNAPSHOT
+ environment:
+ spring.kafka.bootstrap-servers: kafka:9092
+ spring.kafka.client-id: acks-0
+ spring.kafka.producer.acks: 0
+
+ consumer:
+ image: juplo/toolbox
+ command: kafkacat -C -b kafka:9092 -t test -o 0 -f'p=%p|o=%o|k=%k|v=%s\n'
@Override
public void run(ApplicationArguments args)
{
- for (int i = 0; i < 100; i++)
+ for (int i = 0; true; i++)
{
// tag::callback[]
ListenableFuture<SendResult<String, String>> listenableFuture =
result.getRecordMetadata().offset()),
e -> log.error("ERROR sendig message", e));
// end::callback[]
+
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ return;
+ }
}
}
package de.juplo.kafka;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.kafka.test.context.EmbeddedKafka;
"spring.kafka.template.default-topic=" + TOPIC
})
@EmbeddedKafka(topics = TOPIC)
+@Disabled
public class ApplicationTests
{
public final static String TOPIC = "out";