Skip to content

feat: Add KafkaRecord POJO types for raw Kafka record binding#236

Open
TsuyoshiUshio wants to merge 1 commit intoAzure:devfrom
TsuyoshiUshio:feature/kafka-record-types
Open

feat: Add KafkaRecord POJO types for raw Kafka record binding#236
TsuyoshiUshio wants to merge 1 commit intoAzure:devfrom
TsuyoshiUshio:feature/kafka-record-types

Conversation

@TsuyoshiUshio
Copy link
Copy Markdown
Collaborator

Summary

Add KafkaRecord, KafkaHeader, KafkaTimestamp, and KafkaTimestampType POJO types to enable users to bind to raw Apache Kafka records with full metadata access in their function signatures.

Issue

Relates to Azure/azure-functions-kafka-extension#612
Relates to Azure/azure-functions-java-worker#868

Changes

File Description
KafkaRecord.java Main POJO: topic, partition, offset, key/value as raw byte[], timestamp, headers, leaderEpoch. Includes getKeyAsString() and getValueAsString() convenience methods
KafkaHeader.java Header: key (String) + value (byte[]) + getValueAsString() helper
KafkaTimestamp.java Timestamp: getUnixTimestampMs(), getType(), getDateTimeOffset() (returns OffsetDateTime)
KafkaTimestampType.java Enum: NotAvailable(0), CreateTime(1), LogAppendTime(2) with fromValue() safe mapping

All types are in com.microsoft.azure.functions package, consistent with existing Kafka types like KafkaMessageKeyType, BrokerAuthenticationMode, etc.

Breaking Changes

None. All existing types unchanged.

Note

This PR provides the user-facing types. The worker-side Protobuf deserializer (which converts host-sent ModelBindingData to KafkaRecord) is in a separate PR: Azure/azure-functions-java-worker#869.

Release order: This library must be released first, then the worker PR can update its dependency version.

Add types that enable users to bind to raw Apache Kafka records with full
metadata access in their function signatures.

New files:
- KafkaRecord.java — Main POJO with topic, partition, offset, key/value
  as raw bytes, timestamp, headers, leader epoch + convenience helpers
- KafkaHeader.java — Header with key + byte[] value + getValueAsString()
- KafkaTimestamp.java — Timestamp with getUnixTimestampMs(), getType(),
  getDateTimeOffset()
- KafkaTimestampType.java — Enum: NotAvailable, CreateTime, LogAppendTime
  with fromValue() safe mapping

Non-breaking: All existing types unchanged. Package: com.microsoft.azure.functions

Relates to Azure/azure-functions-kafka-extension#612

Co-authored-by: Dobby <dobby@microsoft.com>
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