API reference

August 26, 2026 ยท View on GitHub

Every public type in 1.4.0, grouped by module. Types not listed here are package-private implementation details and are not part of the compatibility surface.

The full Javadoc is browsable at https://krabka-io.github.io/krabka-streams-java/. Javadoc is also published alongside each artifact (-javadoc.jar) and is generated with Xdoclint:all plus -Werror, so every public type and member carries a complete comment. Every public type and package summary includes a runnable-style usage example.


krabka-streams

Package io.krabka.streams.

KrabkaStreamsConfig

public final class. A utility class that cannot be instantiated.

MemberSignature
GROUP_PROTOCOL_CONFIGpublic static final String = "group.protocol"
STREAMS_GROUP_PROTOCOLpublic static final String = "streams"
withDefaultspublic static Properties withDefaults(Map<?, ?> settings)

withDefaults copies settings into a new Properties and applies krabka defaults with putIfAbsent. Throws NullPointerException for a null argument.

Everything else in this module is the Apache Kafka Streams 4.3.1 API, re-exported as an api dependency.


krabka-streams-schema-serde

Package io.krabka.streams.schema.

KrabkaSchemaRegistryClient

public final class. An asynchronous Confluent Schema Registry REST client.

MemberSignature
constructorKrabkaSchemaRegistryClient(URI baseUri)
constructorKrabkaSchemaRegistryClient(URI baseUri, HttpClient httpClient, ObjectMapper objectMapper)
constructorKrabkaSchemaRegistryClient(URI baseUri, String username, String password)
constructorinjected client plus int maxRetries
registerCompletableFuture<Integer> register(String subject, SchemaKind kind, String schema, String messageType)
lookupCompletableFuture<Integer> lookup(String subject, SchemaKind kind, String schema, String messageType)
latestCompletableFuture<RegisteredSchema> latest(String subject)
latestIdCompletableFuture<Integer> latestId(String subject)
schemaByIdCompletableFuture<FetchedSchema> schemaById(int schemaId)
managementsubjects, versions, compatibility, deletion, and reference resolution methods

Nested records:

public record SchemaReference(String name, String subject, int version) {}

public record RegisteredSchema(..., List<SchemaReference> references) {}

public record FetchedSchema(String schema, String messageType, List<SchemaReference> references) {}

Failures complete the future exceptionally with SchemaRegistryException.

SchemaCache

public final class. A thread-safe store of resolved schema IDs and writer schemas.

MemberSignature
constructorSchemaCache(KrabkaSchemaRegistryClient client), which uses AUTO_REGISTER and TopicNameStrategy
constructorSchemaCache(KrabkaSchemaRegistryClient client, RegisterMode registerMode, SubjectNameStrategy subjectNameStrategy)
subjectString subject(String topic, Role role)
internvoid intern(String subject, SchemaKind kind, String schema, String messageType), idempotent by subject
prewarmCompletableFuture<Void> prewarm()
prewarmReportCompletableFuture<PrewarmReport> prewarmReport()
idForSubjectOptionalInt idForSubject(String subject)
writerSchemaString writerSchema(int schemaId), which throws SchemaFetchPendingException on a miss
writerMessageTypeString writerMessageType(int schemaId), null when unknown
writerReferencesMap<String, String> writerReferences(int schemaId)
seedSubjectIdvoid seedSubjectId(String subject, int schemaId)
seedWriterSchemavoid seedWriterSchema(int schemaId, String schema)
seedWriterMessageTypevoid seedWriterMessageType(int schemaId, String messageType)

AvroSerde<T>

public final class ... implements Serde<T>

MemberSignature
forValuestatic <T extends SpecificRecord> AvroSerde<T> forValue(Class<T> type, SchemaCache cache)
forKeystatic <T extends SpecificRecord> AvroSerde<T> forKey(Class<T> type, SchemaCache cache)
genericstatic AvroSerde<GenericRecord> generic(Schema schema, SchemaCache cache, Role role)
reflectstatic <T> AvroSerde<T> reflect(Class<T> type, SchemaCache cache, Role role)
registerSubjectvoid registerSubject(String topic)
serializer / deserializerfrom Serde<T>

Registers the Avro canonical parsing form. Deserialization performs writer/reader schema resolution.

ProtobufSerde<T extends Message>

public final class ... implements Serde<T>

MemberSignature
forValuestatic <T extends Message> ProtobufSerde<T> forValue(T defaultInstance, SchemaCache cache)
forKeystatic <T extends Message> ProtobufSerde<T> forKey(T defaultInstance, SchemaCache cache)
registerSubjectvoid registerSubject(String topic)

Uses the Protobuf message-index framing and verifies the writer's messageType.

JsonSchemaSerde<T>

public final class ... implements Serde<T>

MemberSignature
forValuestatic <T> JsonSchemaSerde<T> forValue(Class<T> type, String schema, SchemaCache cache, boolean validate)
forKeystatic <T> JsonSchemaSerde<T> forKey(Class<T> type, String schema, SchemaCache cache, boolean validate)
forValuestatic <T> JsonSchemaSerde<T> forValue(Class<T> type, String schema, SchemaCache cache, boolean validate, ObjectMapper objectMapper)
registerSubjectvoid registerSubject(String topic)

validate applies in both directions. $schema selects Draft 4, 6, 7, 2019-09, or 2020-12; an extended factory accepts an explicit dialect, strategy, and mapper.

ConfluentWireFormat

public final class. Framing helpers.

MemberSignature
MAGICpublic static final byte = 0
encodestatic byte[] encode(int schemaId, byte[] body)
decodestatic Frame decode(byte[] bytes)
encodeProtobufstatic byte[] encodeProtobuf(int schemaId, List<Integer> messageIndexes, byte[] body)
decodeProtobufstatic ProtobufFrame decodeProtobuf(byte[] bytes)
public record Frame(int schemaId, byte[] body) {}

public record ProtobufFrame(int schemaId, List<Integer> messageIndexes, byte[] body) {}

Both records copy body on construction and on access.

LocalSchemaCompatibility

Network-free pairwise checks for BACKWARD, FORWARD, and FULL modes. avro and json accept schema text; protobuf accepts two FileDescriptor values. Every check returns Result(boolean compatible, List<String> incompatibilities).

Enums and interfaces

TypeValues / members
RoleKEY, VALUE
SchemaKindAVRO (no wire name), PROTOBUF, JSON
RegisterModeAUTO_REGISTER, LOOKUP_ONLY, USE_LATEST
SubjectNameStrategy@FunctionalInterface String subject(String topic, Role role)
TopicNameStrategyimplements SubjectNameStrategy, producing topic + "-key" or topic + "-value"

Exceptions

TypeExtendsMembers
SchemaRegistryExceptionRuntimeExceptionSchemaRegistryException(String), (String, Throwable), (int statusCode, String body); int statusCode(), which returns -1 for transport or parsing errors
SchemaFetchPendingExceptionorg.apache.kafka.common.errors.RetriableExceptionSchemaFetchPendingException(int schemaId); int schemaId()

krabka-streams-columnar

Package io.krabka.streams.columnar.

ColumnarTopology

public final class. The topology builder.

MemberSignature
constructorColumnarTopology(BufferAllocator allocator)
addSourceColumnarNode addSource(String name, Collection<String> topics, BatchCodec codec)
addOperatorColumnarNode addOperator(String name, BuiltinOp operator, ColumnarNode parent)
addOperatorColumnarNode addOperator(String name, Supplier<? extends ColumnarProcessor> processor, ColumnarNode parent)
addMergeColumnarNode addMerge(String name, Collection<ColumnarNode> parents)
addJoinColumnarNode addJoin(String name, ColumnarJoin join, ColumnarNode left, ColumnarNode right)
addSinkColumnarNode addSink(String name, String topic, BatchCodec codec, ColumnarNode parent)
addPassThroughSinkColumnarNode addPassThroughSink(String name, String topic, ColumnarNode source)
sourceTopicsList<String> sourceTopics()
validatevoid validate(), which throws ColumnarException
buildBuiltColumnarTopology build()

BuiltColumnarTopology

public final class. Validated, stateful, reusable, and synchronized.

MemberSignature
runBatchList<ProducedToTopic> runBatch(String topic, List<ConsumedRecord> records)
runBatchesList<ProducedToTopic> runBatches(Map<String, List<ConsumedRecord>> input)
runPartitionBatchesevaluates one co-partitioned input map
state lifecyclesnapshotPartition, restorePartition, releasePartition, and close

ColumnarNode

public final class. An opaque parent handle with no public members.

ColumnarRunner

public final class. A utility class.

public static long runPartitionOnce(
    ColumnarTopology topology,
    Consumer<byte[], byte[]> consumer,
    Producer<byte[], byte[]> producer,
    String topic,
    int partition,
    long offset,
    Duration pollTimeout)

Commits and returns the next offset. group(...) creates a subscribed reusable runner; group runners provide ordinary and transactional runOnce methods. The full overload accepts ColumnarErrorPolicy, ColumnarStateStore, and ColumnarMetrics. sendAsync returns a CompletableFuture<Void> for broker acknowledgements.

Runner support types:

  • ColumnarErrorPolicy: fail(), skip(), or deadLetter(topic).
  • ColumnarMetrics: lock-free counters exposed through an immutable Snapshot.
  • ColumnarStateStore: load(int partition, long epoch) and save(int partition, long epoch, Map<String, byte[]> snapshot); LIVE_EPOCH is the rebalance state and none() is ephemeral.
  • FileColumnarStateStore: atomically replaced snapshot files under a caller-owned path, in the container the three krabka streams libraries share.

The seven-argument group overload also accepts a BarrierAlignment. A runner built with one exposes pendingCut(), restoreToEpoch(long), and restoreToLatestCut().

Codecs

TypeSignature
BatchCodecinterface: decode/encode methods, with default topic-aware overloads
BlobCodecfinal class implements BatchCodec: BlobCodec(BufferAllocator), BlobCodec(BufferAllocator, int maxRecordBytes)
GzipBatchCodecfinal class implements BatchCodec: bounded GZIP decorator for another codec
RowCodec<T>final class implements BatchCodec: RowCodec(Serde<T> valueSerde, RowBridge<T> rowBridge, BufferAllocator allocator)
ArrowIpcSerdefinal class implements Serde<VectorSchemaRoot>: ArrowIpcSerde(BufferAllocator)

BlobCodec constants: DEFAULT_MAX_RECORD_BYTES (900 * 1024), KEY_COLUMN (__key), TIMESTAMP_COLUMN (__timestamp), PARTITION_COLUMN (__partition), OFFSET_COLUMN (__offset), HEADERS_COLUMN (__headers), plus payloadColumn(String) for escaped collisions.

Row bridges

TypeSignature
RowBridge<T>interface: VectorSchemaRoot rowsToBatch(List<T> rows, BufferAllocator), List<T> batchToRows(VectorSchemaRoot)
JsonRowBridge<T>constructors accept Class<T>, optional ObjectMapper or Arrow Schema; fromJsonSchema derives fields

ArrowValues

public final class of static helpers for RowBridge and ColumnarProcessor implementations, exposing the same type-coercing conversions the built-in operators use:

static VectorSchemaRoot createRoot(List<Field> fields, int rows, BufferAllocator allocator)
static void set(FieldVector vector, int row, Object value)
static Object get(FieldVector vector, int row)
static void finish(VectorSchemaRoot root)

Operators

TypeSignature
ColumnarProcessor@FunctionalInterface void process(ColumnarContext context, VectorSchemaRoot batch)
StatefulColumnarProcessorprocessor plus snapshot() and restore(byte[])
ColumnarContextfinal class: void forward(VectorSchemaRoot batch)
RowPredicate@FunctionalInterface boolean test(VectorSchemaRoot batch, int row)
RowValue@FunctionalInterface Object value(VectorSchemaRoot batch, int row)
DerivedColumnrecord DerivedColumn(Field field, RowValue value)
Aggregationrecord Aggregation(String inputColumn, String outputColumn, AggregateFunction function, ArrowType outputType)
AggregateFunctionenum: COUNT, SUM, MIN, MAX

BuiltinOp is a public final class implements ColumnarProcessor:

static BuiltinOp filter(BufferAllocator allocator, RowPredicate predicate)
static BuiltinOp select(BufferAllocator allocator, String... columns)
static BuiltinOp withColumns(BufferAllocator allocator, DerivedColumn... columns)
static BuiltinOp groupBy(
    BufferAllocator allocator, Collection<String> keys, Aggregation... aggregations)
static BuiltinOp windowedGroupBy(
    BufferAllocator allocator,
    Collection<String> keys,
    Duration size,
    Aggregation... aggregations)
static BuiltinOp windowedGroupBy(
    BufferAllocator allocator,
    Collection<String> keys,
    Duration size,
    Duration retention,
    Aggregation... aggregations)
void process(ColumnarContext context, VectorSchemaRoot batch)

Records and exceptions

public record RecordHeader(String key, byte[] value) {}

public record ConsumedRecord(..., List<RecordHeader> headers) {}

public record ProduceRecord(..., List<RecordHeader> headers) {}

public record ProducedToTopic(String topic, ProduceRecord record) {}

public record ColumnarJoin(
    String leftKey, String rightKey, Duration window, String leftPrefix, String rightPrefix) {}

public final class ColumnarException extends RuntimeException {
  public ColumnarException(String message);

  public ColumnarException(String message, Throwable cause);
}

ConsumedRecord and ProduceRecord copy their byte arrays on construction and on access. value must not be null; key may be.

Barrier alignment

Package io.krabka.streams.columnar.barrier. See Barrier alignment for usage.

TypeSignature
BarrierCutrecord BarrierCut(String group, long epoch, long triggeredAt, long completedAt, BarrierCutStatus status, Map<TopicPartition, Long> offsets, Set<TopicPartition> missing)
BarrierCutStatusenum: COMPLETE, PARTIAL; code() and fromCode(int)
BarrierCutDecoderfinal class: static Optional<BarrierCut> decode(byte[] key, byte[] value); TOPIC is __barrier_state
BarrierCutReaderfinal class: BarrierCutReader(Consumer<byte[], byte[]>), optional Duration; latestCompleteCut(String) and completeCutsAfter(String, long)
BarrierAlignmentrecord BarrierAlignment(String group, BarrierCutReader reader, BarrierListener listener); on(String, BarrierCutReader) and withListener
BarrierListenerinterface: void onBarrier(BarrierCut cut); none()

BarrierCut members: complete(), offset(TopicPartition) returning OptionalLong, recordsBefore(TopicPartition, List<ConsumedRecord>), and reached(TopicPartition, long position). The offsets and the missing partitions are copied on construction, so a decoded cut is immutable.


krabka-streams-columnar-schema

Package io.krabka.streams.columnar.schema. See Columnar processing for usage. The module depends on both krabka-streams-columnar and krabka-streams-schema-serde, plus protobuf-java-util as an implementation dependency for the canonical Protobuf JSON fallback.

AvroBatchCodec

public final class implements BatchCodec

MemberSignature
genericstatic AvroBatchCodec generic(Schema schema, SchemaCache cache, BufferAllocator allocator)
forValuestatic <T extends SpecificRecord> AvroBatchCodec forValue(Class<T> type, SchemaCache cache, BufferAllocator allocator)
registerSubjectvoid registerSubject(String topic)
arrowSchemaSchema arrowSchema() (Arrow), the payload columns without metadata columns
decode/encodethe four BatchCodec methods

ProtobufBatchCodec

public final class implements BatchCodec

MemberSignature
ofstatic <T extends Message> ProtobufBatchCodec of(T defaultInstance, SchemaCache cache, BufferAllocator allocator)
registerSubjectvoid registerSubject(String topic)
arrowSchemaSchema arrowSchema() (Arrow), the payload columns without metadata columns
decode/encodethe four BatchCodec methods

Row bridges and schema converters

TypeSignature
AvroRowBridge<T extends IndexedRecord>implements RowBridge<T>: generic(Schema), forSpecific(Class<T>), arrowSchema()
ProtobufRowBridge<T extends Message>implements RowBridge<T>: of(T defaultInstance), arrowSchema()
AvroArrowSchemasstatic Schema toArrowSchema(org.apache.avro.Schema), static Field toArrowField(String, org.apache.avro.Schema)
ProtobufArrowSchemasstatic Schema toArrowSchema(Descriptor), static Field toArrowField(FieldDescriptor)

The bridges derive their Arrow schema once, at construction, from the reader schema or message descriptor; mid-stream writer evolution never changes the columns. Conversion choices that the Arrow type alone cannot reverse are tagged with krabka.avro.*, krabka.proto.*, or krabka.json field metadata.


krabka-streams-coordination

Package io.krabka.streams.coordination. See Coordination for usage. The module depends on krabka-streams for the pinned Kafka client version and uses the producer, consumer, and admin clients only.

Role, MemberId

public final class, each Comparable and each built by one factory.

MemberSignature
MAX_LENGTHpublic static final int = 249 bytes, on both types
ofstatic Role of(String name), static MemberId of(String id)
accessorString name() on Role, String id() on MemberId
bytesbyte[] bytes() on Role, the UTF-8 name the partition rule hashes

Both factories throw CoordinationException for an empty name and for a name past the byte bound. A Role becomes a Kafka transactional.id.

FencingToken

public final class implements Comparable<FencingToken>

MemberSignature
NO_EPOCHpublic static final FencingToken, the role no member has ever taken
ofstatic FencingToken of(long producerId, short producerEpoch)
parsestatic FencingToken parse(String text), the id:epoch form
producerIdlong producerId()
producerEpochshort producerEpoch()
mintedboolean minted()
compareTolexicographic: producer id first, then producer epoch
supersedesboolean supersedes(FencingToken other)

of rejects a negative value in either position.

Record types and codec

TypeSignature
RecordKindenum: REGISTRATION (0), LEASE (1); code(), fromCode(short)
CoordinationValuesealed interface permits Registration, Lease: kind(), member()
Registrationrecord(MemberId member, long registeredAt)
Leaserecord(MemberId member, FencingToken token, long grantedAt, long deadline)
CoordinationKeyrecord(RecordKind kind, Role role, Optional<MemberId> member)
CoordinationEntryrecord(long offset, CoordinationKey key, Optional<CoordinationValue> value)
CoordinationCodecTOPIC, encodeKey, encodeValue, decodeKey, decodeValue, isTombstone
RolePartitionerDEFAULT_PARTITIONS = 16; static int partitionFor(Role role, int partitions)

CoordinationKey.registration(Role, MemberId) and CoordinationKey.lease(Role) build a key that keeps the member rule of the frozen layout. decodeValue returns an empty Optional for a tombstone.

Lease policy and clock

TypeSignature
LeaseConfigdefaults(), of(Duration, Duration, Duration), duration(), renewInterval(), challengeStagger(), renewsWithMargin()
LeaseConfigchallengeDelayMillis(int rank), grant(MemberId, FencingToken, long), timing(Lease)
LeaseTiminglease(), expiresAtMillis(), liveAt(long), remainingAt(long), renewAtMillis(), renewDueAt(long)
LeaseTimingchallengeAtMillis(int rank)
Clocklong nowMillis(); static Clock system()
ManualClockManualClock(long nowMillis), set(long), advance(Duration)

The defaults are a 30-second lease, a 10-second renew interval, and a 5-second challenge stagger. of rejects an extent that is not positive and a renew interval that is not shorter than the duration.

Succession

TypeSignature
RosterEntryrecord(MemberId member, long offset, long registeredAt)
RoleStateempty(), fromRecords(Role, Iterable<CoordinationEntry>)
RoleStateroster(), lease(), holder(), entry(MemberId), rankOf(MemberId)
RoleStateBuilderRoleStateBuilder(Role), role(), apply(CoordinationEntry), build()
Decisionrecord(Decision.Action action, long waitUntilMillis)
Decision.ActionNOT_REGISTERED, HOLD, CHALLENGE, WAIT
Successionstatic Decision evaluate(RoleState, MemberId, long nowMillis, LeaseConfig)

The rules perform no input and no output. rankOf returns an OptionalInt, and the rank is the index in the roster after the removal of the current holder.

Transport and client

TypeSignature
CoordinationTransportacquireEpoch, readRoleRecords, register, writeLease, clearLease, describe, close
KafkaCoordinationTransport(Admin, Producer, Function<Role, Producer>, Consumer) and an overload that takes a poll timeout
CoordinationClient(CoordinationTransport) and (CoordinationTransport, LeaseConfig, Clock, Duration)
CoordinationClientconfig(), readState(Role), describe(Role), tryAcquire(Role, MemberId), acquire(...)
Leadershiprole(), member(), token(), lease(), timing(), held(), renewDue(), renew(), resign()
LeadershipStatusrecord(Role role, FencingToken token, RoleState state); holder(), lease(), held(), current()
CoordinationExceptionpublic class extends RuntimeException
FencedExceptionpublic final class extends CoordinationException; role()

Leadership is AutoCloseable and resigns on close. FencedException is the only signal that a leadership ended.


krabka-streams-test-utils

Package io.krabka.streams.test. See Testing for usage.

ColumnarTestDriver

public final class

MemberSignature
constructorColumnarTestDriver(BuiltColumnarTopology topology)
pipeInputoverloads accept record bytes and optional List<RecordHeader>
pipeBatchvoid pipeBatch(String topic, List<ConsumedRecord> records)
failNextinjects one RuntimeException before the next batch evaluation
isOutputEmptyboolean isOutputEmpty(String topic)
outputSizeint outputSize(String topic)
readOutputProduceRecord readOutput(String topic), which throws NoSuchElementException
drainOutputList<ProduceRecord> drainOutput(String topic)

SchemaRegistryStub

public final class ... implements AutoCloseable

MemberSignature
constructorSchemaRegistryStub() throws IOException, which binds 127.0.0.1 on an ephemeral port
uriURI uri()
requestCountint requestCount(String method, String path)
closevoid close()

This module also re-exports Apache Kafka's kafka-streams-test-utils, including TopologyTestDriver.


Compatibility

Nothing is deprecated yet. The public surface above is what future releases will be judged against; package-private types (AbstractSchemaSerde, ArrowBatchSupport, BridgeMetadata, ProtobufSchemaPrinter) may change at any time.

Transitive api dependencies are part of the surface too: Kafka Streams 4.3.1, Avro 1.12.1, Protobuf 4.33.5, Jackson 2.22.0, and Arrow 19.0.0.