Nisarg Patil
Nisarg Patil

Reputation: 1649

Add unique value to a key in Kafka message using Kouncil

I have a json payload that I am using to produce a kafka message via Kouncil, json is as below:

{
    "version": "1.0",
    "id": "product-1730976584",
    "source": "product-service"
}

I want to generate lot of these messages and need a unique product id every time. In the example above I have used epoch in seconds (as suffix), and I am doing this thing manually for every event.
Is there a way I can add a timestamp kind of suffix to achieve this? Something like "id": "product-{{epochInSeconds}}"
I am using epoch here, but it can be any uique id generator (like UUID or anything else)
I am aware of how to achieve this for HTTP APIs via Postman.


EDIT: As suffix need not be a numeric value, how about having <topicName>-<partitionId>-<offset> as a suffix , it will be unique but is there a way to use these as a placeholder variables?

Upvotes: 0

Views: 24

Answers (0)

Related Questions