import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;
-import javax.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotEmpty;
@RestController
public class RecorderController
{
private final String topic;
- private final KafkaProducer<String, String> producer;
+ private final KafkaProducer<User, Recording> producer;
- public RecorderController(RecorderApplicationProperties properties, KafkaProducer<String,String> producer)
+ public RecorderController(
+ RecorderApplicationProperties properties,
+ KafkaProducer<User, 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<User, Recording> record = new ProducerRecord<>(
+ topic,
+ User.of(username),
+ Recording.of(username, sentence));
+
producer.send(record, (metadata, exception) ->
{
if (metadata != null)