Skip to content

Feature/protobuf runtime generation#145

Merged
bascunansalvador merged 28 commits into
feature/protobuf-schema-artifactsfrom
feature/protobuf-runtime-generation
Jun 18, 2026
Merged

Feature/protobuf runtime generation#145
bascunansalvador merged 28 commits into
feature/protobuf-schema-artifactsfrom
feature/protobuf-runtime-generation

Conversation

@bascunansalvador

Copy link
Copy Markdown
Collaborator

!! Experimental !!

Add type-safe spring-kafka API support for native Protobuf payloads.

Previously, the generator could emit native .proto schema artifacts, but Spring Kafka client generation did not understand those payloads as usable API types. Protobuf payloads were still rejected by the generator compatibility checks, which meant generated producers, consumers, listeners, and handlers could not reference Protobuf message classes.

The proposed solution adds a native Protobuf payload type resolver. It reads the .proto content from the AsyncAPI multi-format schema and resolves the Java type that generated Kafka APIs should use.

For Protobuf payloads, the resolver uses option java_package when it is present. If java_package is not defined, it falls back to the Protobuf package. The resolver also requires option java_multiple_files = true;, because that makes the Protobuf message available as a top-level Java type that generated Kafka APIs can reference directly.

The .proto schema must also contain a top-level message with the same name as the payload. If the schema is missing a usable package, missing java_multiple_files = true, or missing the expected message declaration, the generator now fails with a domain-specific error that explains what must be fixed.

Spring Kafka generation was updated to resolve native multi-format payloads through a shared NativeKafkaPayloadResolver. This keeps native Avro and native Protobuf handling in one place before the Java and Kotlin generator factories build their producer, consumer, listener, and handler models.

With this change, generated Spring Kafka APIs can now reference Protobuf payload types directly.

bascunansalvador and others added 28 commits June 13, 2026 00:48
Introduce shared message header analysis so generated Spring Kafka producers and consumers can use typed header DTOs when AsyncAPI message headers are defined.

The Spring Kafka model preparation now carries header type metadata through the analyzer, payload model, Java/Kotlin factories, and templates. Generated producer and consumer APIs now include typed header parameters for messages with headers, while no-header messages keep the existing simpler signatures.

Producer templates now map non-null typed header values into Kafka record headers, and consumer templates expose the generated header type in handler signatures.

Add tests covering header analysis, Java Spring Kafka generation, and
Kotlin Spring Kafka generation so typed header imports, method
signatures, and producer header mapping remain stable.
…eration

Feature/protobuf java payload generation
@bascunansalvador bascunansalvador merged commit 64f9264 into feature/protobuf-schema-artifacts Jun 18, 2026
1 check passed
@bascunansalvador bascunansalvador deleted the feature/protobuf-runtime-generation branch June 18, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant