Skip to content
OpenSmartRoute
Skillv1.0.0

kafka-expert

Expert-level Apache Kafka, event streaming, Kafka Streams, and distributed messaging. Use when the user mentions streaming, messaging, event driven, or Kafka Streams.

by personamanagmentlayer(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from personamanagmentlayer/pcl (stdlib/data/kafka-expert/SKILL.md). Install upstream with npx skills add personamanagmentlayer/pcl --skill kafka-expert. Copyright stays with the author.

Apache Kafka Expert

Expert guidance for Apache Kafka, event streaming, Kafka Streams, and building event-driven architectures.

Core Concepts

  • Topics, partitions, and offsets
  • Producers and consumers
  • Consumer groups
  • Kafka Streams
  • Kafka Connect
  • Exactly-once semantics

Producer

from kafka import KafkaProducer
import json

producer = KafkaProducer(
    bootstrap_servers=['localhost:9092'],
    value_serializer=lambda v: json.dumps(v).encode('utf-8'),
    acks='all',  # Wait for all replicas
    retries=3
)

# Send message
future = producer.send('user-events', {
    'user_id': '123',
    'event': 'login',
    'timestamp': '2024-01-01T00:00:00Z'
})

# Wait for acknowledgment
record_metadata = future.get(timeout=10)
print(f"Topic: {record_metadata.topic}, Partition: {record_metadata.partition}")

producer.flush()
producer.close()

Consumer

from kafka import KafkaConsumer

consumer = KafkaConsumer(
    'user-events',
    bootstrap_servers=['localhost:9092'],
    group_id='my-group',
    auto_offset_reset='earliest',
    enable_auto_commit=False,
    value_deserializer=lambda m: json.loads(m.decode('utf-8'))
)

for message in consumer:
    print(f"Received: {message.value}")

    # Process message
    process_event(message.value)

    # Manual commit
    consumer.commit()

Kafka Streams

Properties props = new Properties();
props.put(StreamsConfig.APPLICATION_ID_CONFIG, "streams-app");
props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");

StreamsBuilder builder = new StreamsBuilder();

KStream<String, String> source = builder.stream("input-topic");

// Transform and filter
KStream<String, String> transformed = source
    .filter((key, value) -> value.length() > 10)
    .mapValues(value -> value.toUpperCase());

transformed.to("output-topic");

KafkaStreams streams = new KafkaStreams(builder.build(), props);
streams.start();

Best Practices

  • Use appropriate partition keys
  • Monitor consumer lag
  • Implement idempotent producers
  • Use consumer groups for scaling
  • Set proper retention policies
  • Handle rebalancing gracefully
  • Monitor cluster metrics

Anti-Patterns

❌ Single partition topics ❌ No error handling ❌ Ignoring consumer lag ❌ Producing to wrong partitions ❌ Not using consumer groups ❌ Synchronous processing ❌ No monitoring

Resources

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/personamanagmentlayer-pcl-kafka-expert/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

personamanagmentlayer-pcl-kafka-expert.ocm.jsonjson
{
  "ocm": "1",
  "id": "personamanagmentlayer-pcl-kafka-expert",
  "kind": "skill",
  "name": "kafka-expert",
  "description": "Expert-level Apache Kafka, event streaming, Kafka Streams, and distributed messaging. Use when the user mentions streaming, messaging, event driven, or Kafka Streams.",
  "publisher": "personamanagmentlayer",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "kafka",
      "streaming",
      "messaging",
      "event-driven",
      "kafka-streams",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Expert-level Apache Kafka, event streaming, Kafka Streams, and distributed messaging. Use when the user mentions streaming, messaging, event driven, or Kafka Streams."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/personamanagmentlayer/pcl",
      "path": "stdlib/data/kafka-expert/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/personamanagmentlayer/pcl/blob/HEAD/stdlib/data/kafka-expert/SKILL.md",
      "key": "personamanagmentlayer/pcl/stdlib/data/kafka-expert/SKILL.md"
    },
    "allowed_tools": [
      "Read",
      "Write",
      "Edit",
      "Bash(kafka:*)"
    ]
  },
  "instructions": "# Apache Kafka Expert\n\nExpert guidance for Apache Kafka, event streaming, Kafka Streams, and building event-driven architectures.\n\n## Core Concepts\n\n- Topics, partitions, and offsets\n- Producers and consumers\n- Consumer groups\n- Kafka Streams\n- Kafka Connect\n- Exactly-once semantics\n\n## Producer\n\n```python\nfrom kafka import KafkaProducer\nimport json\n\nproducer = KafkaProducer(\n    bootstrap_servers=['localhost:9092'],\n    value_serializer=lambda v: json.dumps(v).encode('utf-8'),\n    acks='all',  # Wait for all replicas\n    retries=3\n)\n\n# Send message\nfuture = producer.send('user-events', {\n    ",
  "cost": {
    "context_tokens": 614
  }
}

Fetch it by URL: GET /api/v1/registry/personamanagmentlayer-pcl-kafka-expert/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.