Custom Converters and Post Processors
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Legacy schemas encode meaning in types that the new model does not share. The Bookshop Oracle schema stores whether a
book is on sale in ACTIVE_FLG CHAR(1) with the values 'Y' and 'N'; the new book table has active boolean.
Other legacy schemas store dates as NUMBER(8) values such as 20261109, or booleans as NUMBER(1). Debezium maps
each source column type to a Kafka Connect type with fixed rules (see
Data Types & Precision), so by default ACTIVE_FLG reaches
Kafka as the string "Y", and every consumer has to know what "Y" means.
You can fix that in three places: in each consumer (the anti-corruption layer), in an SMT after the event is built (see Debezium Transformations), or inside the connector, before the event exists. This page is about the last option. It has two mechanisms:
-
A custom converter changes how one column is mapped: its Kafka Connect schema type and the conversion of its values. Because the schema itself says
boolean, every consumer, schema registry and sink sees a boolean. -
A post processor changes a finished event inside Debezium before it becomes a Kafka Connect record, with access to Debezium’s internals such as the database connection. Debezium ships one that re-reads columns whose values were not in the transaction log, and one that offloads very large values to Amazon S3.
Checked on 2026-11-09 against Debezium 3.7.1.Final and Apache Kafka 4.3.1 (the Kafka version Debezium 3.7.1.Final is
built against). The Maven module on this page, with both converters and their unit tests, was compiled and tested
with Maven on Java 21 against io.debezium:debezium-api:3.7.1.Final and org.apache.kafka:connect-api:4.3.1. It was
not deployed into a running Oracle connector; the connector and post processor configurations are derived from the
official documentation and were not run.
Where converters and post processors run
| Custom converter | Post processor | SMT | |
|---|---|---|---|
Acts on |
One column type, while the event is built |
The finished event, as mutable structs, before the |
The |
Changes the schema? |
Yes, it defines the field’s schema |
It can change values; the reselect processor keeps the schema |
Yes |
Has access to |
Column metadata (name, table, type, length, default) |
Debezium internals: the relational model, the database connection |
Only the record |
Supported by |
Relational source connectors. Not MongoDB, not the JDBC sink. |
Source connectors. Not the JDBC sink. |
Source and sink connectors, Debezium Server, the Engine |
Deployed as |
A JAR in the connector’s plug-in directory, configured with |
Built in (or an extra module), configured with |
Built in, or a JAR, configured with |
The name "converter" means two different things in this pipeline. A Kafka Connect converter (key.converter,
value.converter) serializes the finished record into bytes as JSON, Avro or Protobuf (see
Serialization & Schema Registries). A Debezium
custom converter is configured with the connector property converters and maps one source column type to one
field. This page is about the second kind.
Built-in custom converters
Before writing one, check whether Debezium already ships the conversion. The Oracle connector provides three:
| Class | Conversion |
|---|---|
|
|
|
|
|
|
Each takes an optional selector, a regular expression matched against <data collection>.<column>; without it the
converter applies to every column of the type.
converters=number-to-boolean
number-to-boolean.type=io.debezium.connector.oracle.converters.NumberOneToBooleanConverter
number-to-boolean.selector=.*.MY_TABLE.DATA
The MySQL and MariaDB connectors ship io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter,
ZeroDateFallbackConverter and JdbcSinkDataTypesConverter in the same way (see
MySQL & MariaDB Connectors). None of them handles
CHAR(1) 'Y'/'N' flags, so the Bookshop needs its own.
The CustomConverter SPI
A custom converter implements io.debezium.spi.converter.CustomConverter from the debezium-api module:
public interface CustomConverter<S, F extends ConvertedField> {
@FunctionalInterface
interface Converter {
Object convert(Object input);
}
public interface ConverterRegistration<S> {
void register(S fieldSchema, Converter converter);
}
void configure(Properties props);
void converterFor(F field, ConverterRegistration<S> registration);
}
Reference: Debezium — Implementing custom converters
For the relational connectors the type parameters are SchemaBuilder (Kafka Connect’s schema builder) and
RelationalColumn. The life cycle:
-
When the connector starts, Debezium creates one instance per name listed in
convertersand callsconfigure()with that converter’s properties (the connector properties prefixed with<name>., with the prefix removed). -
For every column of every captured table, Debezium calls
converterFor(). If the converter wants the column, it callsregistration.register(schema, converter)once. If it does not callregister, Debezium uses its default mapping. -
For every value of a registered column, Debezium calls the
Converterfunction, also for snapshot reads.
RelationalColumn describes the column. In debezium-api 3.7.1.Final it has these methods (the first two come from
ConvertedField):
| Method | Returns |
|---|---|
|
The column name, as the database reports it ( |
|
The table identifier; match it with a regular expression rather than an exact string. |
|
The database type name ( |
|
The full type expression. |
|
The JDBC type code and the native type code. |
|
|
|
Whether the column is nullable. |
|
The column default, if any. |
|
The character set (a default method). |
Custom converters are found through the converters property, by class name. There is no META-INF/services file to
write.
A converter for CHAR(1) 'Y'/'N' flags
The YesNoToBooleanConverter below registers a Kafka Connect BOOLEAN schema for selected CHAR(1) (or NCHAR(1))
columns and maps 'Y' to true and 'N' to false. Design decisions, each one a lesson from real legacy data:
-
An explicit selector is required. A converter that silently turns every
CHAR(1)column into a boolean would also hitCUSTOMER.STATUS_CD('A'/'I'), and the connector would fail on the first'A'. Requiringselectorkeeps the scope deliberate. -
Unknown values fail by default. A legacy column constrained to
'Y'/'N'sometimes contains'y',' 'or'X'anyway. The converter accepts any case and trims blank padding, but a truly unknown value throws aDataException, which stops the connector. That is a safer default for a migration than inventingfalse. Setunknown.value.handling=nullto emitnullinstead. -
The schema is plain
SchemaBuilder.bool(). Debezium adds the optional flag and the default value itself, as the built-inNumberOneToBooleanConverterrelies on. ForNOT NULLcolumns with a default, anullinput falls back to the converted default. -
Values are converted from
toString(). Depending on the connector adapter and on snapshot versus streaming, aCHAR(1)value can arrive as aStringor another type, and the default value can arrive quoted ('Y').
The Maven module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.bookshop</groupId>
<artifactId>bookshop-debezium-converters</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<!-- Debezium connectors run on Java 17+, so the converter targets 17 -->
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.debezium>3.7.1.Final</version.debezium>
<!-- The Kafka version that Debezium 3.7.1.Final is built against -->
<version.kafka>4.3.1</version.kafka>
<version.junit>5.13.4</version.junit>
</properties>
<dependencies>
<!-- Both are already on the Kafka Connect / connector class path: never package them -->
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-api</artifactId>
<version>${version.debezium}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-api</artifactId>
<version>${version.kafka}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
</plugins>
</build>
</project>
The official page lists debezium-api and connect-api as compile dependencies, with ${version.debezium} set to
the connector version and ${version.kafka} to the Kafka version of your environment. The provided scope compiles
against them without packaging them: the connector’s plug-in directory already contains debezium-api, and Kafka
Connect provides connect-api. A second copy in your JAR can cause class-loading conflicts.
The converter class
package com.example.bookshop.migration.converters;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.errors.DataException;
import io.debezium.spi.converter.CustomConverter;
import io.debezium.spi.converter.RelationalColumn;
/**
* Emits legacy Oracle CHAR(1) 'Y'/'N' flag columns as Kafka Connect BOOLEAN fields.
*
* <p>Configuration (prefixed with the converter's symbolic name in the connector config):
* <ul>
* <li>{@code selector}: required, comma-separated regular expressions matched (case-insensitively)
* against {@code <data collection>.<column>}, for example {@code .*BOOKSHOP\.BOOK\.ACTIVE_FLG}</li>
* <li>{@code true.values}: comma-separated values that mean true (default {@code Y})</li>
* <li>{@code false.values}: comma-separated values that mean false (default {@code N})</li>
* <li>{@code unknown.value.handling}: {@code fail} (default) or {@code null}</li>
* </ul>
*/
public class YesNoToBooleanConverter implements CustomConverter<SchemaBuilder, RelationalColumn> {
public static final String SELECTOR = "selector";
public static final String TRUE_VALUES = "true.values";
public static final String FALSE_VALUES = "false.values";
public static final String UNKNOWN_VALUE_HANDLING = "unknown.value.handling";
private List<Pattern> selectors;
private Set<String> trueValues;
private Set<String> falseValues;
private boolean failOnUnknown;
@Override
public void configure(Properties props) {
String selector = props.getProperty(SELECTOR);
if (selector == null || selector.isBlank()) {
throw new IllegalArgumentException("The '" + SELECTOR + "' property is required: "
+ "name the CHAR(1) flag columns explicitly, for example .*BOOKSHOP\\.BOOK\\.ACTIVE_FLG");
}
selectors = Arrays.stream(selector.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(s -> Pattern.compile(s, Pattern.CASE_INSENSITIVE))
.toList();
trueValues = parseValues(props.getProperty(TRUE_VALUES, "Y"));
falseValues = parseValues(props.getProperty(FALSE_VALUES, "N"));
String handling = props.getProperty(UNKNOWN_VALUE_HANDLING, "fail").trim().toLowerCase(Locale.ROOT);
if (!handling.equals("fail") && !handling.equals("null")) {
throw new IllegalArgumentException("'" + UNKNOWN_VALUE_HANDLING + "' must be 'fail' or 'null', was '"
+ handling + "'");
}
failOnUnknown = handling.equals("fail");
}
@Override
public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBuilder> registration) {
if (!isCharOne(column) || !isSelected(column)) {
return; // not ours: Debezium keeps its default mapping (a STRING field)
}
// Debezium itself makes the field optional and applies the column default,
// as for the built-in Oracle NumberOneToBooleanConverter.
registration.register(SchemaBuilder.bool(), value -> toBoolean(column, value));
}
private boolean isCharOne(RelationalColumn column) {
String type = column.typeName() == null ? "" : column.typeName().toUpperCase(Locale.ROOT);
return (type.equals("CHAR") || type.equals("NCHAR")) && column.length().orElse(-1) == 1;
}
private boolean isSelected(RelationalColumn column) {
String fullName = column.dataCollection() + "." + column.name();
return selectors.stream().anyMatch(p -> p.matcher(fullName).matches());
}
private Object toBoolean(RelationalColumn column, Object value) {
if (value == null) {
if (column.isOptional()) {
return null;
}
if (column.hasDefaultValue() && column.defaultValue() != null) {
return toBoolean(column, column.defaultValue());
}
throw new DataException("NULL in NOT NULL column " + column.dataCollection() + "." + column.name());
}
if (value instanceof Boolean b) {
return b; // already converted (for example a default value)
}
// CHAR(1) values can arrive as String or Character, sometimes blank-padded or quoted (DDL defaults)
String text = value.toString().trim().replace("'", "").toUpperCase(Locale.ROOT);
if (trueValues.contains(text)) {
return Boolean.TRUE;
}
if (falseValues.contains(text)) {
return Boolean.FALSE;
}
if (failOnUnknown) {
throw new DataException("Unexpected flag value '" + value + "' in "
+ column.dataCollection() + "." + column.name() + "; expected one of "
+ trueValues + " or " + falseValues);
}
return null;
}
private static Set<String> parseValues(String csv) {
return Arrays.stream(csv.split(","))
.map(s -> s.trim().toUpperCase(Locale.ROOT))
.filter(s -> !s.isEmpty())
.collect(Collectors.toUnmodifiableSet());
}
}
Reference: Debezium — Custom converter methods
A unit test without a database
The SPI is small enough to test with a hand-written RelationalColumn. The test runs in milliseconds and proves the
selector and the value mapping before anything is deployed.
package com.example.bookshop.migration.converters;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.sql.Types;
import java.util.OptionalInt;
import java.util.Properties;
import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.errors.DataException;
import org.junit.jupiter.api.Test;
import io.debezium.spi.converter.CustomConverter.Converter;
import io.debezium.spi.converter.RelationalColumn;
class YesNoToBooleanConverterTest {
@Test
void convertsActiveFlagToBoolean() {
Registration registration = register(column("FREEPDB1.BOOKSHOP.BOOK", "ACTIVE_FLG", "CHAR", 1, true));
assertNotNull(registration.converter, "ACTIVE_FLG must be converted");
assertEquals(Schema.Type.BOOLEAN, registration.schema.type());
assertEquals(Boolean.TRUE, registration.converter.convert("Y"));
assertEquals(Boolean.FALSE, registration.converter.convert("n "));
assertNull(registration.converter.convert(null));
assertThrows(DataException.class, () -> registration.converter.convert("X"));
}
@Test
void ignoresOtherColumns() {
assertNull(register(column("FREEPDB1.BOOKSHOP.CUSTOMER", "STATUS_CD", "CHAR", 1, true)).converter);
assertNull(register(column("FREEPDB1.BOOKSHOP.BOOK", "CURRENCY", "CHAR", 3, true)).converter);
}
private static Registration register(RelationalColumn column) {
YesNoToBooleanConverter converter = new YesNoToBooleanConverter();
Properties props = new Properties();
props.setProperty("selector", ".*BOOKSHOP\\.BOOK\\.ACTIVE_FLG");
converter.configure(props);
Registration registration = new Registration();
converter.converterFor(column, (schema, conv) -> {
registration.schema = schema;
registration.converter = conv;
});
return registration;
}
private static final class Registration {
SchemaBuilder schema;
Converter converter;
}
private static RelationalColumn column(String table, String name, String type, int length, boolean optional) {
return new RelationalColumn() {
@Override public String name() { return name; }
@Override public String dataCollection() { return table; }
@Override public int jdbcType() { return Types.CHAR; }
@Override public int nativeType() { return -1; }
@Override public String typeName() { return type; }
@Override public String typeExpression() { return type; }
@Override public OptionalInt length() { return OptionalInt.of(length); }
@Override public OptionalInt scale() { return OptionalInt.empty(); }
@Override public boolean isOptional() { return optional; }
@Override public Object defaultValue() { return null; }
@Override public boolean hasDefaultValue() { return false; }
};
}
}
Reference: Debezium — Debezium custom converter example
The test uses FREEPDB1.BOOKSHOP.BOOK as the data collection, but the selector starts with .*, so it also matches if
the connector reports the table without the database name. Check the real value once, in the connector log or in a
test against the Oracle container (see Testing CDC Pipelines),
before you tighten the expression.
A second converter: packed NUMBER(8) dates
The Bookshop schema has no packed dates, but many legacy schemas store dates as NUMBER(8) in YYYYMMDD form, with
0 for "no date". The same pattern produces a Kafka Connect DATE field, which the JDBC sink writes into a PostgreSQL
date column. It lives in the same module and was tested in the same build.
package com.example.bookshop.migration.converters;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Locale;
import java.util.Properties;
import java.util.regex.Pattern;
import org.apache.kafka.connect.data.Date;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.errors.DataException;
import io.debezium.spi.converter.CustomConverter;
import io.debezium.spi.converter.RelationalColumn;
/**
* Emits legacy NUMBER(8) columns that hold dates as YYYYMMDD (for example 20261109) as Kafka Connect DATE fields.
* The value 0 is treated as "no date" and emitted as null. The required {@code selector} property is a regular
* expression matched (case-insensitively) against {@code <data collection>.<column>}.
*/
public class PackedNumberDateConverter implements CustomConverter<SchemaBuilder, RelationalColumn> {
private static final DateTimeFormatter YYYYMMDD = DateTimeFormatter.BASIC_ISO_DATE;
private Pattern selector;
@Override
public void configure(Properties props) {
String value = props.getProperty("selector");
if (value == null || value.isBlank()) {
throw new IllegalArgumentException("The 'selector' property is required");
}
selector = Pattern.compile(value.trim(), Pattern.CASE_INSENSITIVE);
}
@Override
public void converterFor(RelationalColumn column, ConverterRegistration<SchemaBuilder> registration) {
boolean isNumber = "NUMBER".equalsIgnoreCase(column.typeName());
boolean isSelected = selector.matcher(column.dataCollection() + "." + column.name()).matches();
if (!isNumber || !isSelected) {
return;
}
// Debezium makes the field optional when the column is nullable
registration.register(Date.builder(), value -> toDate(column, value));
}
private Object toDate(RelationalColumn column, Object value) {
if (value == null) {
return null;
}
long packed;
try {
packed = value instanceof Number n
? new BigDecimal(n.toString()).longValueExact()
: new BigDecimal(value.toString().trim()).longValueExact();
}
catch (ArithmeticException | NumberFormatException e) {
throw new DataException("Not a packed date in " + column.name() + ": '" + value + "'", e);
}
if (packed == 0L) {
return null; // the legacy "no date" marker
}
try {
LocalDate date = LocalDate.parse(String.format(Locale.ROOT, "%08d", packed), YYYYMMDD);
// Kafka Connect DATE values are java.util.Date at midnight UTC
return java.util.Date.from(date.atStartOfDay(ZoneOffset.UTC).toInstant());
}
catch (DateTimeParseException e) {
throw new DataException("Invalid packed date in " + column.name() + ": " + packed, e);
}
}
}
Reference: Debezium — Implementing custom converters
Two limits: returning null for 0 only works when the column is nullable (otherwise the field is not optional and
the record fails), and the conversion relies on toString() for non-Number inputs. The built-in Oracle
NumberOneToBooleanConverter also handles the Oracle driver’s own oracle.sql.NUMBER type; if your converter ever
receives that type, add the Oracle JDBC driver as a provided dependency and handle it explicitly.
Packaging and deploying the converter
Build the JAR with mvn package. Because both dependencies are provided, the JAR contains only your classes.
The official procedure is to copy the JAR into the plug-in directory of each connector that uses it. Kafka Connect
loads each plug-in directory with its own class loader, so a JAR in the Oracle connector’s directory is invisible to
the PostgreSQL connector. In the Debezium Connect image the plug-in directories are under /kafka/connect.
FROM quay.io/debezium/connect:3.7.1.Final
# The Oracle connector also needs the Oracle JDBC driver in this directory (see the Oracle Connector page)
COPY target/bookshop-debezium-converters-1.0.0.jar /kafka/connect/debezium-connector-oracle/
Reference: Debezium — Deploying a custom converter
On Kubernetes with Strimzi, add the JAR as an artifact of the Oracle connector plug-in in the KafkaConnect build
(see Running on Kubernetes). Restart the worker after changing a
plug-in directory.
Registering the converter on bookshop-oracle-source
A converter is enabled with the converters property, which lists symbolic names, and one <name>.type property per
name. Every other property that starts with <name>. is passed to configure() without the prefix.
{
"converters": "activeFlag",
"activeFlag.type": "com.example.bookshop.migration.converters.YesNoToBooleanConverter",
"activeFlag.selector": ".*BOOKSHOP\\.BOOK\\.ACTIVE_FLG",
"activeFlag.true.values": "Y",
"activeFlag.false.values": "N",
"activeFlag.unknown.value.handling": "fail"
}
The keys go into the config object of bookshop-oracle-source, next to the LogMiner settings described on
Oracle Connector (the connector property is documented as
converters in the Oracle connector’s property list). Use PUT http://localhost:8083/connectors/bookshop-oracle-source/config
with the complete configuration to apply it. Several converters are listed comma-separated, for example
"converters": "activeFlag,packedDates".
The change event for a book then carries a boolean (the payload part of the value is shown; BOOK_ID is a string
because the Bookshop source uses decimal.handling.mode=string):
{ "after": { "BOOK_ID": "1001", "TITLE": "Patterns of Legacy", "ACTIVE_FLG": "Y", "...": "..." } }
{ "after": { "BOOK_ID": "1001", "TITLE": "Patterns of Legacy", "ACTIVE_FLG": true, "...": "..." } }
Introducing a converter on a running pipeline
Adding the converter changes the schema of the legacy.BOOKSHOP.BOOK value: ACTIVE_FLG changes from an optional
string to an optional boolean. Plan for that, because every component that remembers the old schema reacts:
-
Schema registry. With Avro or another registry-backed format, a string-to-boolean change is incompatible under the usual
BACKWARDcompatibility mode, and the connector fails to register the new schema. Either register the converter before the first snapshot, or change the subject’s compatibility for this one migration step. -
JDBC sink mirror tables. The mirror table
legacy_bookhasactive_flg char(1), created by hand forbookshop-pg-mirror-sink(which runs withschema.evolution=none). Even withschema.evolution=basicthe sink only adds missing columns; it never changes the type of an existing one. Depending on the column type and the database’s casting rules, the writes then fail or storetrue/falseas text next to the oldY/Nvalues. Create the mirror with the right type, or alter the column before deploying the converter. If the mirror tables must stay an exact 1:1 copy of the legacy columns for reconciliation, do not convert at the source at all, and translateACTIVE_FLGinLegacyBookTranslatorinstead. -
Consumers.
LegacyBookTranslatormust accept both shapes during the switch, or be deployed after the topic has been re-snapshotted. -
Old events. Events already in the topic keep the string. If consumers replay from the beginning, they see both. A blocking or incremental snapshot of
BOOKSHOP.BOOKafter the change refreshes every key with the new type (see Incremental & Blocking Snapshots).
The easiest time to add converters is before the initial snapshot of the pipeline. That is a good reason to profile the legacy columns (distinct values of every flag and code column) while you design the pipeline, not after.
Post processors
Post processors run inside Debezium on the finished event, before Kafka Connect builds the SourceRecord. Because they
work on mutable structs and can use Debezium’s database connection and relational model, they can do things an SMT
cannot, such as querying the source database. They are configured like converters, with a post.processors list of
names and post.processors.<name>.type, and they run in the order listed. They work with Debezium source connectors
only.
Debezium 3.7 provides two:
| Post processor | Purpose |
|---|---|
Reselect columns ( |
Re-reads columns whose values are missing from the event: TOASTed PostgreSQL columns, Oracle LOBs and Exadata extended strings that the change did not touch. |
S3 large message ( |
Uploads large string and bytes values to Amazon S3 and replaces them with a reference. |
Reselect columns: values that are not in the log
Databases store large values out of line, and when an update does not change such a column, its value is not written
to the transaction log. Debezium cannot invent it, so it emits the unavailable.value.placeholder sentinel instead (for
a string column, __debezium_unavailable_value by default). A sink that writes this event literally replaces a
real value with the placeholder text, which is one of the most damaging silent errors in a migration.
In the Bookshop the problem shows up in reverse replication. bookshop-pg-source captures the new public.book table
so that changes can flow back to Oracle (see Cut-over &
Reverse Replication). A long title is stored as TOAST in PostgreSQL. When the new application changes only the
price of such a book, the update event carries the placeholder in title, unless the table has
REPLICA IDENTITY FULL (see PostgreSQL Connector). The reselect
post processor fixes the event by querying the current value.
{
"post.processors": "reselector",
"post.processors.reselector.type": "io.debezium.processors.reselect.ReselectColumnsPostProcessor",
"post.processors.reselector.reselect.columns.include.list": "public.book:title",
"post.processors.reselector.reselect.unavailable.values": "true",
"post.processors.reselector.reselect.null.values": "false",
"post.processors.reselector.reselect.use.event.key": "false",
"post.processors.reselector.reselect.error.handling.mode": "FAIL",
"post.processors.reselector.reselect.cache.enabled": "true",
"post.processors.reselector.reselect.cache.max.size": "10000",
"post.processors.reselector.reselect.cache.ttl.ms": "600000"
}
The official options table lists the properties as post.processors.reselect.*; in a configuration they are prefixed
with the post processor’s name, as in the example above.
Property (after post.processors.<name>.) |
Default | Meaning |
|---|---|---|
|
none |
|
|
none |
Columns to reselect, as |
|
none |
Columns never to reselect. |
|
|
Reselect columns that hold the unavailable value placeholder. |
|
|
Reselect columns that are |
|
|
Build the |
|
|
|
|
|
Cache reselected values per row and column. |
|
|
Cache implementation;
|
|
|
Bounds of the in-memory cache. |
Things to understand before you enable it:
-
It reads the current value, not the value at the time of the change. If the row changed again after the event, the reselected value is newer than the rest of the event. For a migration that applies events in order and ends with the latest state, that is usually fine; for an audit trail it is not.
-
Each reselection is a query on the source database. On a busy table, enable the cache, which is refreshed whenever an event carries a real value for the column.
-
A deleted row cannot be reselected. With
WARNthe event keeps the placeholder;FAILmakes the gap visible. In a migration pipeline,FAILplus an alert is the safer choice. -
For Oracle LOBs the same post processor applies with
lob.enabled=trueon the Oracle connector and the Oracle<schema>.<table>:<column>names (for exampleBOOKSHOP.<table>:<LOB column>; the running example has no LOB columns).
S3 large message post processor
A few legacy rows can hold values of megabytes (scanned documents in a BLOB, long XML in a CLOB). Such events
can exceed the broker’s message size limit and add memory pressure everywhere. The S3 large message post processor
uploads every STRING or BYTES value above a threshold to Amazon S3 and replaces it with an inline reference of the
form __debezium:s3:ref:v1:<bucket-name>|<object-key>. It needs the debezium-storage-s3 module on the connector’s
plug-in path.
{
"post.processors": "s3offloader",
"post.processors.s3offloader.type": "io.debezium.storage.s3.processor.S3LargeMessagePostProcessor",
"post.processors.s3offloader.large.message.s3.bucket.name": "bookshop-cdc-large-values",
"post.processors.s3offloader.large.message.s3.region.name": "eu-west-1",
"post.processors.s3offloader.large.message.s3.threshold.bytes": "102400",
"post.processors.s3offloader.large.message.s3.columns.include.list": "DOCUMENT_BODY",
"post.processors.s3offloader.large.message.s3.error.handling.mode": "fail",
"post.processors.s3offloader.large.message.s3.endpoint": "http://minio:9000"
}
Property (after post.processors.<name>.) |
Default | Meaning |
|---|---|---|
|
none |
Required. Bucket for the offloaded values. |
|
none |
Required. Region of the bucket. |
|
|
Minimum size of a value to offload. |
|
none |
Static credentials. Without them, the
AWS |
|
none |
Endpoint of an S3-compatible store (MinIO, LocalStack); switches to path-style addressing. |
|
none |
Regular expressions of field names eligible for offloading. |
|
none |
Regular expressions of field names never offloaded. |
|
|
|
The DOCUMENT_BODY column and the MinIO endpoint are illustrative: remove endpoint for Amazon S3 itself, and keep
credentials out of the connector configuration (use the credentials chain or a Kafka configuration provider, see
Security & Data Protection).
The reference replaces the value in Kafka, so every consumer must resolve it. The Debezium JDBC sink does not
download offloaded values: it would write the reference string into the target column. Use this post processor only
for columns that your own consumers resolve (for example a LegacyDocumentTranslator that fetches the object and
stores it), or that the new system does not migrate. The object key is built from the event’s source block plus the
field name and before/after; for the core connectors it is unique per event.
What goes wrong
| Symptom | Cause and fix |
|---|---|
|
The JAR is not in the plug-in directory of this connector, or the worker was not restarted. |
|
The JAR bundles |
The converter has no effect |
The selector does not match |
The connector stops with |
The legacy data contains a value outside the configured sets. Profile the column, then extend |
Schema registration fails after deploying a converter |
The field type changed incompatibly. See "Introducing a converter on a running pipeline". |
|
TOAST or LOB values were not in the log. Use |
Target columns contain |
The S3 post processor offloaded values that a sink does not resolve. |
Verifying converters and post processors
-
Run the unit tests (
mvn verify) for every converter, with the real values found while profiling the legacy column. -
Validate the connector configuration before applying it:
PUT http://localhost:8083/connector-plugins/io.debezium.connector.oracle.OracleConnector/config/validate. -
Update one row and read the value schema of the event (JSON converter with
schemas.enable=true, or the registry subject):ACTIVE_FLGmust be"type": "boolean". -
Compare the target with the legacy table for that column, for example
SELECT COUNT(*) FROM BOOKSHOP.BOOK WHERE ACTIVE_FLG = 'Y'againstSELECT count(*) FROM book WHERE active. Verification & Reconciliation generalises this. -
For the reselect post processor, update a non-TOAST column of a row with a large TOASTed value and check that the target row keeps the real value.
kafka-console-consumer.sh --bootstrap-server localhost:9092 \
--topic legacy.BOOKSHOP.BOOK --max-messages 1 \
| jq '.schema.fields[] | select(.field == "after") | .fields[] | select(.field == "ACTIVE_FLG")'
This requires the topic to be written with the JSON converter and value.converter.schemas.enable=true, which is
how bookshop-oracle-source is configured.