Tek İleti Dönüşümleri (SMT'ler)
Kafka Connect Single Message Transforms'ın bağlayıcılar ile Kafka arasındaki kayıtları akış işlemcisi yazmadan satır içinde nasıl yeniden şekillendirdiğini öğrenin.
Tek İleti Dönüşümleri (SMT'ler), CoddyKit'te ücretsiz bir Apache Kafka & Stream Processing Fundamentals dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Apache Kafka & Stream Processing Fundamentals öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Apache Kafka & Stream Processing Fundamentals kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
What Are SMTs?
Single Message Transforms (SMTs) are lightweight functions applied to each record as it flows through a Kafka Connect connector.
They let you tweak data — rename fields, add metadata, route topics — without a separate processing job.
Where SMTs Run
SMTs run inside the connector worker:
- For a source connector, after reading from the system and before writing to Kafka.
- For a sink connector, after reading from Kafka and before writing to the target.
Configuring a Transform
Transforms are configured declaratively in the connector's JSON or properties. You name the chain, then configure each transform.
{
"transforms": "addTs",
"transforms.addTs.type":
"org.apache.kafka.connect.transforms.InsertField$Value",
"transforms.addTs.timestamp.field": "ingestedAt"
}Common Built-in SMTs
Kafka Connect ships many useful transforms:
InsertField— add a static or metadata field.ReplaceField— rename or drop fields.MaskField— redact sensitive values.ExtractField— pull one field up as the whole value.
Routing with RegexRouter
RegexRouter rewrites the destination topic name, handy for adding prefixes when ingesting many tables.
{
"transforms": "route",
"transforms.route.type":
"org.apache.kafka.connect.transforms.RegexRouter",
"transforms.route.regex": "(.*)",
"transforms.route.replacement": "db_$1"
}Chaining Transforms
List multiple transforms separated by commas; they run in order, each receiving the previous one's output.
{
"transforms": "mask,route",
"transforms.mask.type":
"org.apache.kafka.connect.transforms.MaskField$Value",
"transforms.mask.fields": "ssn,creditCard",
"transforms.route.type":
"org.apache.kafka.connect.transforms.RegexRouter",
"transforms.route.regex": "(.*)",
"transforms.route.replacement": "secure_$1"
}Key vs. Value Variants
Many SMTs come in two forms, suffixed with $Key or $Value, so you can target the record's key or value independently.
For example InsertField$Key versus InsertField$Value.
Predicates
Predicates let a transform apply conditionally — for example, only to tombstone records or to a specific topic.
{
"predicates": "isTomb",
"predicates.isTomb.type":
"org.apache.kafka.connect.transforms.predicates.RecordIsTombstone",
"transforms.drop.predicate": "isTomb"
}When NOT to Use SMTs
SMTs operate on one record at a time. They cannot:
- Join across records or topics.
- Aggregate or window.
- Call external services efficiently.
For those, use Kafka Streams or ksqlDB instead.
Custom SMTs
You can implement your own by writing a class that implements the Transformation interface, packaging it as a JAR, and placing it on the worker plugin path.
public class UppercaseField
implements Transformation<SourceRecord> {
public SourceRecord apply(SourceRecord record) {
// reshape and return the record
return record;
}
}Best Practices
Use SMTs wisely:
- Keep chains short and readable.
- Mask sensitive data as early as possible.
- Prefer predicates over per-topic connectors when filtering.
- Move heavy logic to a stream processor.
Quick Check
Test your understanding of SMTs.
Recap
You learned about Single Message Transforms.
- SMTs reshape each record inline within a connector.
- Use built-ins like InsertField, ReplaceField, MaskField, RegexRouter.
- Chain them and gate with predicates.
- For joins, aggregations, or windows, use a stream processor instead.
Sıkça Sorulan Sorular
“Tek İleti Dönüşümleri (SMT'ler)” dersi ücretsiz mi?
Evet — “Tek İleti Dönüşümleri (SMT'ler)” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Apache Kafka & Stream Processing Fundamentals kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Apache Kafka & Stream Processing Fundamentals kursu toplamda 4 dersten oluşur.
“Tek İleti Dönüşümleri (SMT'ler)” dersinde ne öğreneceğim?
Kafka Connect Single Message Transforms'ın bağlayıcılar ile Kafka arasındaki kayıtları akış işlemcisi yazmadan satır içinde nasıl yeniden şekillendirdiğini öğrenin. Apache Kafka & Stream Processing Fundamentals ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Apache Kafka & Stream Processing Fundamentals öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Apache Kafka & Stream Processing Fundamentals, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Tek İleti Dönüşümleri (SMT'ler)” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Apache Kafka & Stream Processing Fundamentals dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Apache Kafka & Stream Processing Fundamentals dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Kafka Connect'e Giriş
- Alım için Kaynak Bağlayıcıları
- Dışa Aktarım için Hedef Bağlayıcıları
- Tek İleti Dönüşümleri (SMT'ler)