Class TopicNameStrategy

java.lang.Object
io.krabka.streams.schema.TopicNameStrategy
All Implemented Interfaces:
SubjectNameStrategy

public final class TopicNameStrategy extends Object implements SubjectNameStrategy
Uses the Confluent topic naming rule.

A key schema maps to <topic>-key and a value schema to <topic>-value. This matches Confluent's default TopicNameStrategy, so applications sharing topics with Confluent-configured clients resolve the same subjects.

Example

var strategy = new TopicNameStrategy();
strategy.subject("orders", Role.KEY);   // "orders-key"
strategy.subject("orders", Role.VALUE); // "orders-value"
  • Constructor Details

    • TopicNameStrategy

      public TopicNameStrategy()
      Creates the strategy; it is stateless and reusable.
  • Method Details

    • subject

      public String subject(String topic, Role role)
      Returns <topic>-key or <topic>-value depending on the role.
      Specified by:
      subject in interface SubjectNameStrategy
      Parameters:
      topic - the Kafka topic name
      role - whether the schema describes the record key or value
      Returns:
      the topic name with a -key or -value suffix
      Throws:
      NullPointerException - if topic or role is null