-FROM openjdk:11-jre-slim
+FROM eclipse-temurin:17-jre
COPY target/*.jar /opt/app.jar
EXPOSE 8081
ENTRYPOINT ["java", "-jar", "/opt/app.jar"]
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>3.0.2</version>
+ <version>3.2.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>de.juplo.kafka.wordcount</groupId>
<artifactId>recorder</artifactId>
- <version>1.0.2</version>
+ <version>1.1.1</version>
<name>Wordcount-Recorder</name>
<description>Recorder-service of the multi-user wordcount-example</description>
<properties>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.kafka</groupId>
- <artifactId>kafka-clients</artifactId>
+ <groupId>org.springframework.kafka</groupId>
+ <artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
public class RecorderApplication
{
@Bean(destroyMethod = "close")
- KafkaProducer<String, String> producer(RecorderApplicationProperties properties)
+ KafkaProducer<String, Recording> producer(RecorderApplicationProperties properties)
{
Assert.hasText(properties.getBootstrapServer(), "juplo.wordcount.recorder.bootstrap-server must be set");
public class RecorderController
{
private final String topic;
- private final KafkaProducer<String, String> producer;
+ private final KafkaProducer<String, Recording> producer;
- public RecorderController(RecorderApplicationProperties properties, KafkaProducer<String,String> producer)
+ public RecorderController(
+ RecorderApplicationProperties properties,
+ KafkaProducer<String,Recording> producer)
{
this.topic = properties.getTopic();
this.producer = producer;
{
DeferredResult<ResponseEntity<RecordingResult>> result = new DeferredResult<>();
- ProducerRecord<String, String> record = new ProducerRecord<>(topic, username, sentence);
+ ProducerRecord<String, Recording> record = new ProducerRecord<>(
+ topic,
+ username,
+ Recording.of(username, sentence));
+
producer.send(record, (metadata, exception) ->
{
if (metadata != null)
--- /dev/null
+package de.juplo.kafka.wordcount.recorder;
+
+import lombok.Value;
+
+
+@Value(staticConstructor = "of")
+public class Recording
+{
+ String user;
+ String sentence;
+}