단일 메시지 변환(SMT)
Kafka Connect의 단일 메시지 변환이 스트림 프로세서를 작성하지 않고 커넥터와 Kafka 사이에서 레코드를 인라인으로 재구성하는 방식을 배우세요.
단일 메시지 변환(SMT)은(는) CoddyKit의 무료 Apache Kafka & Stream Processing Fundamentals 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Apache Kafka & Stream Processing Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Apache Kafka & Stream Processing Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
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.
자주 묻는 질문
“단일 메시지 변환(SMT)” 강의는 무료인가요?
네 — “단일 메시지 변환(SMT)” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Apache Kafka & Stream Processing Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Apache Kafka & Stream Processing Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
“단일 메시지 변환(SMT)”에서 뭘 배우나요?
Kafka Connect의 단일 메시지 변환이 스트림 프로세서를 작성하지 않고 커넥터와 Kafka 사이에서 레코드를 인라인으로 재구성하는 방식을 배우세요. 브라우저에서 직접 실행하는 실습 코드로 Apache Kafka & Stream Processing Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Apache Kafka & Stream Processing Fundamentals을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Apache Kafka & Stream Processing Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“단일 메시지 변환(SMT)” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Apache Kafka & Stream Processing Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Apache Kafka & Stream Processing Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Kafka Connect 소개
- 수집을 위한 소스 커넥터
- 내보내기를 위한 싱크 커넥터
- 단일 메시지 변환(SMT)