feat: Add KafkaRecord type and Protobuf deserialization for Kafka trigger binding (#868)#869
Open
TsuyoshiUshio wants to merge 2 commits intoAzure:devfrom
Open
feat: Add KafkaRecord type and Protobuf deserialization for Kafka trigger binding (#868)#869TsuyoshiUshio wants to merge 2 commits intoAzure:devfrom
TsuyoshiUshio wants to merge 2 commits intoAzure:devfrom
Conversation
…gger binding Add support for binding to raw Apache Kafka records (KafkaRecord type) in the Java worker, enabling users to access full Kafka message metadata. New files: - KafkaRecord.java — Main POJO with topic, partition, offset, key/value as raw bytes, timestamp, headers, leader epoch - KafkaHeader.java — Header with key + byte[] value + getValueAsString() - KafkaTimestamp.java — Timestamp with UnixTimestampMs + type + getDateTimeOffset() - KafkaTimestampType.java — Enum: NotAvailable, CreateTime, LogAppendTime - KafkaRecordProtoDeserializer.java — Protobuf to POJO conversion - KafkaRecordProto.proto — Shared schema (synced with host extension) - KafkaRecordDeserializerTest.java — 10 unit tests Modified files: - RpcModelBindingDataSource.java — Add content_type dispatch: application/json (existing path) vs application/x-protobuf (new KafkaRecord path) - pom.xml — Add second proto source root for Kafka proto compilation Non-breaking: All existing binding types (String, byte[], Map) unchanged. Users opt in via KafkaRecord parameter type. Relates to Azure/azure-functions-kafka-extension#612 Fixes Azure#868 Co-authored-by: Dobby <dobby@microsoft.com>
Move KafkaRecord, KafkaHeader, KafkaTimestamp, KafkaTimestampType from worker package (com.microsoft.azure.functions.worker.binding.kafka) to library package (com.microsoft.azure.functions) so user functions can import these types in their Maven projects. Worker keeps only KafkaRecordProtoDeserializer (runtime-only code). Co-authored-by: Dobby <dobby@microsoft.com>
Contributor
Author
|
Dependency note: This PR depends on Azure/azure-functions-java-library#236 which adds the The POJO types were initially in this PR but have been moved to the library so that user function code can import them. This PR now contains only the runtime-side changes:
Release order: java-library must be released first → update worker's java-library dependency version → merge this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for binding to raw Apache Kafka records (
KafkaRecordtype) in the Java worker, enabling users to access full Kafka message metadata via Protobuf deserialization.Issue
Fixes #868
Relates to Azure/azure-functions-kafka-extension#612
Changes
New files
KafkaRecord.java— Main POJO with topic, partition, offset, key/value as rawbyte[], timestamp, headers, leader epochKafkaHeader.java— Header with key (String) + value (byte[]) +getValueAsString()helperKafkaTimestamp.java— Timestamp withgetUnixTimestampMs(),getType(),getDateTimeOffset()KafkaTimestampType.java— Enum: NotAvailable, CreateTime, LogAppendTime (withfromValue()safe mapping)KafkaRecordProtoDeserializer.java— Protobuf → KafkaRecord POJO conversionKafkaRecordProto.proto— Shared schema (synced with host extensionMicrosoft.Azure.WebJobs.Extensions.Kafka)KafkaRecordDeserializerTest.java— 10 unit testsModified files
RpcModelBindingDataSource.java— Addcontent_typedispatch:application/json(existing path) vsapplication/x-protobufwith sourceAzureKafkaRecord(new KafkaRecord path). Also addsKafkaRecord.classoperation toDataOperationspom.xml— Add secondprotobuf-maven-pluginexecution for Kafka proto compilation fromsrc/main/proto/kafka/Breaking Changes
None. All existing binding types (
String,byte[],Map<String, String>, POJO) continue to work unchanged. Users opt in viaKafkaRecordparameter type.Testing
User Experience
Note
The host-side counterpart (Kafka Extension 4.3.1) is already released on NuGet. The .NET Isolated Worker implementation was completed in Azure/azure-functions-dotnet-worker#3356.