0

I've been using node-rdkafka npm package for working with node and kafka. For creating a new topic I've been using the following code: client.createTopic({ topic: topic.name, num_partitions: _.get(topic, "partitions", 1), replication_factor: _.get(topic, "replicas", 3) } I need to add topic level retention.ms for overriding the default 7 days set at the broker level. Is there any way to do this using node-rdkafka

1 Answers1

0

I found the solution to this. There is a property 'config' of type object which can be used for this purpose:

client.createTopic({
    'topic': name,
    'num_partitions': partitions,
    'replication_factor': replicas,
    'config': {
        'retention.ms': '60000'
    }
}

This will set the retention.ms to 60000 ms. Note that all the key value pairs passed inside the 'config' parameter must be of type string.