New blog: 🎄 Twelve Days of SMT 🎄 - Day 7: TimestampRouter

Just like the RegExRouter , the TimeStampRouter can be used to modify the topic name of messages as they pass through Kafka Connect. Since the topic name is usually the basis for the naming of the object to which messages are written in a sink connector, this is a great way to achieve time-based partitioning of those objects if required. For example, instead of streaming messages from Kafka to an Elasticsearch index called cars , they can be routed to monthly indices e.g. cars_2020-10 , cars_2020-11 , cars_2020-12 , etc.

The TimeStampRouter takes two arguments; the format of the final topic name to generate, and the format of the timestamp to put in the topic name (based on SimpleDateFormat ).

" transforms " : " addTimestampToTopic " ,

" transforms.addTimestampToTopic.type " : " org.apache.kafka.connect.transforms.TimestampRouter " ,

" transforms.addTimestampToTopic.topic.format " : " ${topic}_${timestamp} " ,

" transforms.addTimestampToTopic.timestamp.format " : " YYYY-MM-dd "


Read more: 🎄 Twelve Days of SMT 🎄 - Day 7: TimestampRouter