OverviewHistoryStatsSecurity
npx skills add ...
Documentation
SKILL.md
npx skills add mindrally/skills --skill kafka-development
Best practices for Apache Kafka event streaming and distributed messaging. Use when building event-driven architectures, implementing producer/consumer patterns, designing topic partitioning strategies, setting up Kafka Streams, configuring schema registries, or integrating change data capture pipelines.
npx skills add mindrally/skills --skill kafka-development
This skill provides best practices for Apache Kafka event streaming and distributed messaging systems. Apply these guidelines when building Kafka-based applications.
acks=all, enable idempotence, select a partition key that distributes evenly, and add error handling with retry logic.enable.auto.commit=false, pick an appropriate auto.offset.reset policy, process messages idempotently, and commit offsets only after successful processing.retention.ms: How long to keep messages (default 7 days)retention.bytes: Maximum size per partitioncleanup.policy: delete (remove old) or compact (keep latest per key)min.insync.replicas: Minimum replicas that must acknowledgebatch.size: Accumulate messages before sending (default 16KB)linger.ms: Wait time for batching (0 = send immediately)buffer.memory: Total memory for buffering unsent messagescompression.type: gzip, snappy, lz4, or zstd for bandwidth savingsauto.offset.reset: earliest (start from beginning) or latest (only new messages)enable.auto.commit=false for exactly-once semanticsgroup.instance.id for static membership to reduce rebalancesProperties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
props.put(ConsumerConfig.GROUP_ID_CONFIG, "order-processing-group");
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)) {
consumer.subscribe(Collections.singletonList("orders"));
while (running) {
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(500));
for (ConsumerRecord<String, String> record : records) {
try {
processOrder(record.key(), record.value());
} catch (Exception e) {
log.error("Failed to process offset={} key={}", record.offset(), record.key(), e);
publishToDeadLetterTopic(record, e);
}
}
consumer.commitSync(); // Commit only after successful processing
}
}