+++ /dev/null
-package de.trion.kafka.outbox;
-
-public class Event {
- public enum Type { CREATED, LOGIN, LOGOUT, DELETED }
-
- Long id;
- Type type;
- String user;
-}
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.kafka.common.serialization.LongSerializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
- public void send(Event event) {
+ public void send(UserEvent event) {
try {
String json = mapper.writeValueAsString(event);
ProducerRecord<String, String> record = new ProducerRecord<>(topic, event.user, json);
--- /dev/null
+package de.trion.kafka.outbox;
+
+public class UserEvent {
+ public enum Type { CREATED, LOGIN, LOGOUT, DELETED }
+
+ Long id;
+ Type type;
+ String user;
+}