azure-functions-kafka-extension
azure-functions-kafka-extension copied to clipboard
Header and Key for Typescript Kafka output binding
Hello,
I tried adding a key and header and writing the message to the Kafka output binding but it's not handled like a key and header, just as part of the Kafka message.
Code:
const messages = []
for (let i = 0; i < 10; i++) {
messages.push({
Headers: [{ Key: "testHeader", Value: "test" + i }],
Key: { testKey: "test" + i * 2 },
Value: { testValue: "test" + i * 3 },
})
}
context.bindings.outputKafkaMessage = messages.map((message) => JSON.stringify(message))
This is the full message as it arrived at my Confluent Cloud Kafka Server, Headers and Key of this message are empty or null
{ "Headers": [ "Key": "testHeader", "Value": "test1" ] }, "Key": { "testKey": "test2", "itemUUID": "optimizationTrigger" }, "Value": { "testValue": "test3" } }
Hi @veastark, You need to set Offset, Partition, Topic and Timestamp also in your each message. Similar to as given in the samples - https://github.com/Azure/azure-functions-kafka-extension/blob/dev/samples/javascript/KafkaOutputManyWithHeaders/index.js#L8
Closing this issue, feel free to reopen if this issue still persists