Add the kafka-basics module

This commit is contained in:
2026-08-29 09:47:25 +05:30
commit 3a682e496e
28 changed files with 1403 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.ankurm.kafkabasics;
import java.math.BigDecimal;
import java.time.Instant;
/**
* The payload. A record works as a Kafka value with no annotations at all, because Jackson 3
* handles records natively — but note that it needs a canonical constructor the
* deserializer can call, which is the one thing a record gives you for free and a Lombok
* {@code @Builder}-only class does not.
*
* @param orderId the partition key. Same customer, same order, same partition, same order of
* delivery — see docs/04-keys-and-partitions.md
*/
public record OrderEvent(String orderId, String customerId, BigDecimal amount, Instant placedAt) {
public static OrderEvent of(String orderId, String customerId, String amount) {
return new OrderEvent(orderId, customerId, new BigDecimal(amount),
Instant.parse("2026-08-29T10:15:30Z"));
}
}