Skip to content

Event Streaming with Kafka ​

OmniNet uses Apache Kafka in KRaft mode (no ZooKeeper) for asynchronous, decoupled event streaming between services.

Event Topics ​

TopicProducerConsumersPurpose
omninet.user.createdauth-servicestorage-service, notes-serviceProvision user folders in S3 and default note categories
omninet.user.updatedauth-servicestorage-servicePropagate profile changes
omninet.file.eventsstorage-servicestorage-serviceQuota reconciliation on upload/delete
omninet.note.eventsnotes-service—Note change auditing
omninet.todo.remindersnotes-service—Todo reminder dispatch from scheduler

Event Flow — User Registration ​

Event Schema — UserCreatedEvent ​

java
public record UserCreatedEvent(
    String userId,
    String email,
    String firstName,
    String lastName,
    Instant createdAt
) {}

Kafka Configuration ​

PropertyValue
ModeKRaft (no ZooKeeper)
Compressionnone (configurable via KAFKA_COMPRESSION_TYPE)
Bootstraplocalhost:9092 (local) / omninet-kafka:9092 (Docker)
Topic replication1 (development)
Consumer group prefixomninet-*

NOTE

Kafka compression was set to none because Alpine Linux containers use musl libc, which is incompatible with Snappy's native JNI library.

Producer Error Handling ​

All Kafka producers wrap publish calls in try-catch blocks to prevent Kafka failures from blocking the main request flow:

java
try {
    kafkaTemplate.send(topic, event);
} catch (Exception e) {
    log.error("Failed to publish Kafka event: {}", e.getMessage());
    // Non-fatal — main operation already completed
}

Released under the MIT License.