I’m using the @KafkaOutput annotation in my Azure Function App to write to my Kafka topic using data from another Kafka topic.
fun run(
@KafkaTrigger(
name = "kafkaTrigger",
topic = "%KafkaGolfSwingInputTopic%",
brokerList="%KafkaBrokerList%",
username = "%KafkaUsername%",
password = "%KafkaPassword%",
authenticationMode = BrokerAuthenticationMode.PLAIN,
protocol = BrokerProtocol.SASLSSL,
consumerGroup = "%KafkaConsumerGroup%",
avroSchema = GOLF_SWING_EVENT_AVRO_SCHEMA,
) kafkaEventData: GolfSwingEventValue?,
@KafkaOutput(
name = "kafkaOutput",
topic = "%KafkaAssessmentSwingOutputTopic%",
brokerList="%KafkaBrokerList%",
username = "%KafkaUsername%",
password = "%KafkaPassword%",
authenticationMode = BrokerAuthenticationMode.PLAIN,
protocol = BrokerProtocol.SASLSSL,
) kafkaOutputBinding: OutputBinding<AssessmentSwingEventValue>,
context: ExecutionContext
) {
...
kafkaOutputBinding.setValue(assessmentSwingEventValue)
Right now I’m just getting the value, which of course is all I’m sending as the OutputBinding
. But I have not been able to find a way to write the value AND the key.
We need the key for partitioning. Nothing I have found so far shows a way to specify that you want a key and a value in the output.
I’m assuming I may need to create my own KafkaProducer, but it’s so much easier to write this annotation!