azure-functions-kafka-extension icon indicating copy to clipboard operation
azure-functions-kafka-extension copied to clipboard

Header and Key for Typescript Kafka output binding

Open veastark opened this issue 3 years ago • 1 comments

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" } }

veastark avatar Aug 24 '22 11:08 veastark

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

krishna-kariya avatar Sep 12 '22 08:09 krishna-kariya

Closing this issue, feel free to reopen if this issue still persists

shrohilla avatar Nov 04 '22 13:11 shrohilla