forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-8082: Pass Headers to Key/Value Converters
- Loading branch information
1 parent
42fbde8
commit 8617f47
Showing
3 changed files
with
113 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
debezium-embedded/src/test/java/io/debezium/embedded/async/FixedValueHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.embedded.async; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.kafka.common.config.ConfigDef; | ||
import org.apache.kafka.connect.connector.ConnectRecord; | ||
import org.apache.kafka.connect.data.Schema; | ||
import org.apache.kafka.connect.header.ConnectHeaders; | ||
import org.apache.kafka.connect.header.Headers; | ||
import org.apache.kafka.connect.transforms.Transformation; | ||
|
||
public class FixedValueHeader<R extends ConnectRecord<R>> implements Transformation<R> { | ||
|
||
@Override | ||
public R apply(R record) { | ||
Headers headers = new ConnectHeaders(); | ||
headers.add("fixed-key", 2, Schema.INT32_SCHEMA); | ||
headers.forEach(h -> record.headers().add(h)); | ||
|
||
return record.newRecord( | ||
record.topic(), | ||
record.kafkaPartition(), | ||
record.keySchema(), | ||
record.key(), | ||
record.valueSchema(), | ||
record.value(), | ||
record.timestamp(), | ||
headers); | ||
} | ||
|
||
@Override | ||
public ConfigDef config() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void configure(Map<String, ?> configs) { | ||
} | ||
|
||
@Override | ||
public void close() { | ||
} | ||
|
||
} |