azure-functions-kafka-extension
azure-functions-kafka-extension copied to clipboard
Support KafkaEventData.Key for Java
Issue
If we want to use KafkaEventData.Key
, it will requires to define your function parameter with the type that has two generic types with KafkaEventData<string, string>
.
public async Task SampleConsumerAsync(
[KafkaTrigger(
"BrokerList",
"repro",
ConsumerGroup = "$Default",
AuthenticationMode = BrokerAuthenticationMode.Plain)] KafkaEventData<string, string>[] kafkaEvents,
ILogger logger)
However, from the other language implementation, there is not way to set KafkaEventData<string, string>
type.
So that it is considered as required key
is false.
https://github.com/Azure/azure-functions-kafka-extension/blob/dd977eda6414490be466ca98d6f01c444470cf2e/src/Microsoft.Azure.WebJobs.Extensions.Kafka/Serialization/SerializationHelper.cs#L124
How to enable it?
- Update the KafkaTriggerAttribute with adding new property e.g.
EnableKey
- Add annotation (or update function.json) to https://github.com/Azure/azure-functions-java-library/tree/dev/src/main/java/com/microsoft/azure/functions/annotation
- Add Unit Test and Language End To End testing for the support.