Outbox Event Router

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Change data capture on business tables tells consumers what changed in a table. During a migration that is often exactly what you want: the anti-corruption layer reads legacy.BOOKSHOP.ORDERS and translates it into the new model. But it also couples every consumer to the table layout. When a team wants to publish domain events instead, events whose names and payloads form a contract that does not change when a column is renamed, it uses the transactional outbox: the application writes the event as a row into an outbox table in the same transaction as the business change, and Debezium turns each new outbox row into a message.

Why the outbox exists, the dual-write problem it removes, the polling publisher alternative and the idempotent consumer are explained on Transactional Outbox. How the router fits into Kafka Connect is outlined on Kafka Connect. This page does not repeat that material. It documents the Debezium side completely: the io.debezium.transforms.outbox.EventRouter SMT and all of its options, its MongoDB counterpart, and the Debezium Outbox Quarkus extension, with Bookshop examples for both the new Spring Boot application and the legacy Oracle schema.

Checked on 2026-11-09 against Debezium 3.7.1.Final, Spring Boot 4.1.2 and the Debezium Outbox Quarkus extension 3.7.1.Final (built against Quarkus 3.33, Java 21). The Spring Boot outbox writer and the Quarkus event classes on this page were compiled (Spring Boot 4.1.2 with Java 21; the Quarkus classes against the extension’s API JAR); the connector configurations are derived from the official documentation and were not run against a live connector.

Outbox events in a migration

There are two places where an outbox helps a strangler-fig migration (see Migration Patterns with CDC):

  • In the new application. The Spring Boot bookshop application owns more and more of the order life cycle. Other services, and eventually the legacy system through reverse replication, must learn about orders placed in the new system. Publishing OrderPlaced from an outbox gives them a stable contract instead of the purchase_order table layout, which is still changing.

  • In the legacy application, when you can change its code. Adding an outbox insert to the legacy order code produces events with business meaning (OrderCancelled) that raw CDC on ORDERS can only guess from a STATUS_CD change from 'PD' to 'CN'. If the legacy code cannot be changed, raw CDC plus an anti-corruption layer is the only option, which is why most of this section relies on it.

In both cases Debezium reads the outbox table from the transaction log, exactly as it reads any other table. The router SMT then turns the raw change event into a clean message: the topic comes from the aggregate type, the key from the aggregate id, and the value from the payload.

sequenceDiagram participant App as bookshop (Spring Boot 4.1) participant PG as PostgreSQL bookshop participant WAL as WAL / pgoutput participant DBZ as bookshop-pg-outbox (Debezium) participant SMT as EventRouter SMT participant K as Kafka App->>PG: BEGIN App->>PG: INSERT INTO purchase_order ... App->>PG: INSERT INTO outbox_event (aggregatetype = 'Order', ...) App->>PG: COMMIT PG->>WAL: commit record WAL->>DBZ: insert event for public.outbox_event DBZ->>SMT: raw change event, op = c SMT->>K: topic outbox.event.Order, key = aggregateid, value = payload, header id

The outbox table

With the default configuration the router expects these columns:

Column Type (PostgreSQL) Role in the emitted message

id

uuid NOT NULL

The unique event id. It becomes the id header, which consumers use to discard duplicates. Option table.field.event.id.

aggregatetype

varchar(255) NOT NULL

Replaces ${routedByValue} in route.topic.replacement, so the default topic is outbox.event.<aggregatetype>. Option route.by.field.

aggregateid

varchar(255) NOT NULL

The message key. All events of one aggregate have the same key, land on the same partition and stay in order. Option table.field.event.key.

type

varchar(255) NOT NULL

The event type (OrderPlaced). Not emitted by default; add it as a header with table.fields.additional.placement.

payload

jsonb

The message value. Option table.field.event.payload.

Any other column can be added to the message as a header, as a field of an envelope, or used to choose the partition.

The outbox table of the new bookshop database
CREATE TABLE outbox_event (
    id            uuid         NOT NULL PRIMARY KEY,
    aggregatetype varchar(255) NOT NULL,
    aggregateid   varchar(255) NOT NULL,
    type          varchar(255) NOT NULL,
    payload       jsonb,
    created_at    timestamptz  NOT NULL DEFAULT now()
);

created_at is not used by the router. It lets you delete old rows and monitor the table. The router ignores deletes on the outbox table, so you can delete rows at any time after they have been written to the log: in the same transaction right after the insert (the Quarkus extension does this by default), or with a periodic DELETE FROM outbox_event WHERE created_at < now() - interval '1 day'. Updating outbox rows, on the other hand, is an error: the table is a queue, and table.op.invalid.behavior decides what happens.

Writing the outbox row from Spring Boot 4.1

The writer must insert the business rows and the outbox row in one local transaction. Nothing else is required: no Kafka client, no retry logic. The service below places an order in the new model and records an OrderPlaced event. It uses JdbcClient and the Jackson 3 JsonMapper that Spring Boot 4 configures, and casts the payload to jsonb.

PlaceOrderService: business write and outbox write in one transaction
package com.example.bookshop.orders;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.UUID;

import org.springframework.jdbc.core.simple.JdbcClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tools.jackson.databind.json.JsonMapper;

@Service
public class PlaceOrderService {

    public record Line(long bookId, int quantity, BigDecimal unitPrice) { }

    /** The event payload: what consumers of outbox.event.Order receive as the record value. */
    public record OrderPlaced(UUID orderId, UUID customerId, Instant placedAt, BigDecimal total, List<Line> lines) { }

    private final JdbcClient jdbc;
    private final JsonMapper jsonMapper;

    public PlaceOrderService(JdbcClient jdbc, JsonMapper jsonMapper) {
        this.jdbc = jdbc;
        this.jsonMapper = jsonMapper;
    }

    @Transactional
    public UUID placeOrder(UUID customerId, List<Line> lines) {
        UUID orderId = UUID.randomUUID();
        Instant placedAt = Instant.now();
        BigDecimal total = lines.stream()
                .map(l -> l.unitPrice().multiply(BigDecimal.valueOf(l.quantity())))
                .reduce(BigDecimal.ZERO, BigDecimal::add);

        // 1. The business write
        jdbc.sql("""
                INSERT INTO purchase_order (id, customer_id, placed_at, status, total)
                VALUES (:id, :customerId, :placedAt, 'NEW', :total)""")
            .param("id", orderId)
            .param("customerId", customerId)
            .param("placedAt", OffsetDateTime.ofInstant(placedAt, ZoneOffset.UTC))
            .param("total", total)
            .update();
        int lineNo = 1;
        for (Line line : lines) {
            jdbc.sql("""
                    INSERT INTO order_line (order_id, line_no, book_id, quantity, unit_price)
                    VALUES (:orderId, :lineNo, :bookId, :quantity, :unitPrice)""")
                .param("orderId", orderId)
                .param("lineNo", lineNo++)
                .param("bookId", line.bookId())
                .param("quantity", line.quantity())
                .param("unitPrice", line.unitPrice())
                .update();
        }

        // 2. The event, in the same transaction: one commit, two tables
        String payload = jsonMapper.writeValueAsString(
                new OrderPlaced(orderId, customerId, placedAt, total, lines));
        jdbc.sql("""
                INSERT INTO outbox_event (id, aggregatetype, aggregateid, type, payload)
                VALUES (:id, 'Order', :aggregateId, 'OrderPlaced', CAST(:payload AS jsonb))""")
            .param("id", UUID.randomUUID())
            .param("aggregateId", orderId.toString())
            .param("payload", payload)
            .update();
        return orderId;
    }
}

The class needs spring-boot-starter-jdbc, spring-boot-starter-jackson and the PostgreSQL driver. The aggregate type Order decides the topic, and the order id is the key, so all events of one order stay in order on one partition. The outbox page in the architecture section shows the same idea with JPA and an envelope with causation and correlation ids; the router does not care which you use, only that the columns match its configuration.

The connector: capture only the outbox

Use a dedicated Debezium connector for the outbox table, separate from the reverse-replication connector bookshop-pg-source. It has its own replication slot and publication, captures only public.outbox_event, and applies the router to every record.

bookshop-pg-outbox: PostgreSQL connector with the outbox event router
{
  "name": "bookshop-pg-outbox",
  "config": {
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "tasks.max": "1",
    "database.hostname": "postgres",
    "database.port": "5432",
    "database.user": "debezium",
    "database.password": "dbz",
    "database.dbname": "bookshop",
    "topic.prefix": "modern-outbox",
    "plugin.name": "pgoutput",
    "slot.name": "bookshop_outbox",
    "publication.name": "bookshop_outbox_pub",
    "publication.autocreate.mode": "filtered",
    "table.include.list": "public.outbox_event",
    "snapshot.mode": "no_data",
    "tombstones.on.delete": "false",

    "key.converter": "org.apache.kafka.connect.storage.StringConverter",
    "value.converter": "org.apache.kafka.connect.json.JsonConverter",
    "value.converter.schemas.enable": "false",

    "transforms": "outbox",
    "transforms.outbox.type": "io.debezium.transforms.outbox.EventRouter",
    "transforms.outbox.route.by.field": "aggregatetype",
    "transforms.outbox.route.topic.replacement": "outbox.event.${routedByValue}",
    "transforms.outbox.table.field.event.id": "id",
    "transforms.outbox.table.field.event.key": "aggregateid",
    "transforms.outbox.table.field.event.payload": "payload",
    "transforms.outbox.table.expand.json.payload": "true",
    "transforms.outbox.table.fields.additional.placement": "type:header:eventType",
    "transforms.outbox.table.op.invalid.behavior": "error"
  }
}

Choices worth explaining:

snapshot.mode=no_data

An initial snapshot would read every row still in the outbox and publish it again. The outbox holds events, not state, so start streaming from the current position. (no_data replaced the deprecated schema_only; see Initial Snapshots.)

publication.autocreate.mode=filtered

The publication contains only the captured table, so the slot does not decode changes of every other table. The PostgreSQL prerequisites (wal_level=logical, the replication user) are on PostgreSQL Connector.

tombstones.on.delete=false

Deletes of outbox rows are cleanup, not events. The router filters delete events, and there is no reason to emit tombstones for them.

table.expand.json.payload=true with JsonConverter

The jsonb payload arrives as a JSON string. Expansion parses it and emits real JSON instead of an escaped string. If parsing fails, or the payload is empty, the content is kept as it is.

key.converter=StringConverter

The key is the aggregateid string. With the JSON converter it would be a quoted JSON string.

table.fields.additional.placement

Adds the type column as a header named eventType, so consumers can choose a handler before parsing the value.

table.op.invalid.behavior=error

An UPDATE on the outbox table is a bug in the writer. warn (the default) logs it, error logs an error, and fatal stops the connector. All three skip the update itself.

topic.prefix does not appear in the output topic names, because the router replaces the topic. It still names the connector’s internal topics and metrics, so it must be unique on the Connect cluster.

The resulting message for the order placed above:

A message on outbox.event.Order
Topic:   outbox.event.Order
Key:     5d1f6f36-7a59-4f3e-9b8e-2a1c0f0e4b11
Headers: id=0b8c4d3e-0f2a-4c66-8a1f-6e1d9c2b7a40, eventType=OrderPlaced
Value:   {"orderId":"5d1f6f36-7a59-4f3e-9b8e-2a1c0f0e4b11","customerId":"8a6c1e4b-4c0d-4a51-9f1e-8f1b2c3d4e5f",
          "placedAt":"2026-11-09T10:15:30.123Z","total":27.80,
          "lines":[{"bookId":1001,"quantity":2,"unitPrice":13.90}]}

A consumer in the bookshop application, or in another service, reads outbox.event.Order like any Kafka topic, and de-duplicates on the id header (at-least-once delivery means duplicates after a connector restart; see Offsets, Restarts & Exactly-Once). The listener side, including idempotency, is covered on Spring Boot and Kafka and Listening to Events in Applications.

All EventRouter options

Option Default Group Description

table.op.invalid.behavior

warn

Table

What to do when the outbox table receives an UPDATE: warn, error or fatal (stop the connector). Deletes are always filtered out.

table.field.event.id

id

Table

Column with the unique event id, emitted as the id header.

table.field.event.key

aggregateid

Table

Column with the message key.

table.field.event.timestamp

none

Table

Column with the message timestamp. Without it, the Debezium event timestamp is used.

table.field.event.payload

payload

Table

Column with the payload.

table.expand.json.payload

false

Table

Parse a JSON string payload into a structure. Needs the JsonConverter.

table.json.payload.null.behavior

ignore

Table

With expansion, how a null inside the JSON payload is handled: ignore or optional_bytes.

table.json.payload.empty.array.behavior

ignore

Table

With expansion, how an empty array is handled: ignore (drop the field) or optional_string (an optional array of optional strings).

table.fields.additional.placement

none

Table, Envelope

Extra columns as column:placement[:alias], comma-separated. Placement is header, envelope or partition.

table.field.additional.missing

error

Table, Envelope

When an additional column is missing: error or ignore.

table.field.event.schema.version

none

Table, Schema

Column whose value is used as the Kafka Connect schema version of the value.

route.by.field

aggregatetype

Router

Column whose value becomes part of the topic name.

route.topic.regex

(?<routedByValue>.*)

Router

Regular expression applied to the route.by.field value.

route.topic.replacement

outbox.event.${routedByValue}

Router

Destination topic, using the groups of route.topic.regex.

route.tombstone.on.empty.payload

false

Router

Emit a tombstone when the payload is empty or null.

tracing.span.context.field

tracingspancontext

Tracing

Column with the serialized tracing span context.

tracing.operation.name

debezium-read

Tracing

Name of the span that represents Debezium’s processing.

tracing.with.context.field.only

false

Tracing

Trace only events that have a span context column.

Topic names

route.topic.regex is matched against the value of the route.by.field column, and route.topic.replacement builds the topic from its groups. The default regex captures the whole value in the named group routedByValue. To publish Order events to bookshop.order.events (lower case is not possible with a regex replacement, so store the aggregate type in the form you want, for example order):

Custom topic names from the aggregate type
transforms.outbox.route.by.field=aggregatetype
transforms.outbox.route.topic.regex=(?<routedByValue>.*)
transforms.outbox.route.topic.replacement=bookshop.${routedByValue}.events

route.topic.regex also restricts the SMT to matching values, which is one of the two ways the official page gives to apply the router selectively; the other is a predicate (see Debezium Transformations). Use a predicate whenever the same connector captures tables other than the outbox.

Additional fields: headers, envelope and partition

table.fields.additional.placement takes column:placement:alias entries:

  • header: the column value becomes a Kafka header named after the alias (or the column).

  • envelope: the message value becomes an envelope that contains payload and the extra field, each as a separate field. Consumers must then read payload from inside the value.

  • partition: the column value is the partition number. An alias has no effect. Use it only when the writer knows the partition count of the topic.

The table of options in the official documentation says that the placement must be header or envelope, while the section on additional fields also documents partition. Test a partition placement on your version before you rely on it.

Event type and schema version as headers, plus an envelope field
transforms.outbox.table.fields.additional.placement=type:header:eventType,schema_version:header:schemaVersion,aggregatetype:envelope:aggregateType
transforms.outbox.table.field.additional.missing=error

This assumes an outbox table with a schema_version column. With table.field.additional.missing=error (the default) a missing column fails the record, which is what you want during development.

Avro payloads

When the writer serializes the payload with Avro (for example with a schema registry serializer) and stores the bytes in a binary column (bytea in PostgreSQL), the connector must pass the bytes through unchanged. Debezium’s io.debezium.converters.BinaryDataConverter does that for the routed records, and delegates all other records (heartbeats, schema change events) to another converter.

Passing Avro payload bytes through, with a delegate converter for other records
transforms=outbox
transforms.outbox.type=io.debezium.transforms.outbox.EventRouter
value.converter=io.debezium.converters.BinaryDataConverter
value.converter.delegate.converter.type=org.apache.kafka.connect.json.JsonConverter
value.converter.delegate.converter.type.schemas.enable=false

The official page also shows Apicurio Registry and Confluent Schema Registry AvroConverter delegates. Every setting for the delegate needs the prefix value.converter.delegate.converter.type., the same prefix as the schemas.enable line above. BinaryDataConverter passes the delegate only the keys under delegate.converter.type., with that prefix removed (checked in the 3.7.1 class, not run). The official Apicurio example uses the shorter prefix value.converter.delegate.converter., so its registry settings never reach the AvroConverter, and it writes the last key as registry.find-latest instead of apicurio.registry.find-latest:

Apicurio Registry as the delegate converter
value.converter=io.debezium.converters.BinaryDataConverter
value.converter.delegate.converter.type=io.apicurio.registry.utils.converter.AvroConverter
value.converter.delegate.converter.type.apicurio.registry.url=http://apicurio:8080/apis/registry/v3
value.converter.delegate.converter.type.apicurio.registry.auto-register=true
value.converter.delegate.converter.type.apicurio.registry.find-latest=true

apicurio:8080 is the registry’s host name inside the Docker network; from the host it is http://localhost:8080. The Apicurio converter classes are not in the plain connector archive; the Debezium Connect image adds them with ENABLE_APICURIO_CONVERTERS=true. The URL uses the Apicurio Registry 3.x path /apis/registry/v3, where the official example shows the older /apis/registry/v2. Registry versions and API paths are covered on Serialization & Schema Registries.

An outbox in the legacy Oracle schema

If the legacy order code can be changed, an outbox table in the BOOKSHOP schema lets it publish real domain events. Oracle has no jsonb, and unquoted Oracle identifiers are upper case, which changes the configuration in two ways: the payload is text, and every column option must name the upper-case column.

A legacy outbox table in BOOKSHOP
CREATE TABLE BOOKSHOP.OUTBOX_EVENT (
    ID            VARCHAR2(36)   NOT NULL PRIMARY KEY,
    AGGREGATETYPE VARCHAR2(255)  NOT NULL,
    AGGREGATEID   VARCHAR2(255)  NOT NULL,
    TYPE          VARCHAR2(255)  NOT NULL,
    PAYLOAD       VARCHAR2(4000),
    CREATED_AT    TIMESTAMP      DEFAULT SYSTIMESTAMP NOT NULL
);

ALTER TABLE BOOKSHOP.OUTBOX_EVENT ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

-- In the legacy order code, inside the same transaction as the UPDATE of ORDERS:
INSERT INTO BOOKSHOP.OUTBOX_EVENT (ID, AGGREGATETYPE, AGGREGATEID, TYPE, PAYLOAD)
VALUES (:eventId, 'LegacyOrder', TO_CHAR(:orderId), 'OrderCancelled',
        '{"orderId":' || TO_CHAR(:orderId) || ',"reason":"customer request"}');
Router settings for the upper-case Oracle outbox columns
{
  "table.include.list": "BOOKSHOP.OUTBOX_EVENT",
  "transforms": "outbox",
  "transforms.outbox.type": "io.debezium.transforms.outbox.EventRouter",
  "transforms.outbox.table.field.event.id": "ID",
  "transforms.outbox.table.field.event.key": "AGGREGATEID",
  "transforms.outbox.table.field.event.payload": "PAYLOAD",
  "transforms.outbox.route.by.field": "AGGREGATETYPE",
  "transforms.outbox.route.topic.replacement": "outbox.event.${routedByValue}",
  "transforms.outbox.table.expand.json.payload": "true",
  "transforms.outbox.table.fields.additional.placement": "TYPE:header:eventType",
  "value.converter": "org.apache.kafka.connect.json.JsonConverter",
  "value.converter.schemas.enable": "false"
}

These keys belong to a separate Oracle connector (for example bookshop-oracle-outbox, with its own topic.prefix and schema history topic) next to bookshop-oracle-source. Adding the router to bookshop-oracle-source would apply it to every captured table unless you add a predicate, and the raw events of BOOK or ORDERS are not outbox rows. The rest of the Oracle configuration (LogMiner, C##DBZUSER, database.pdb.name=FREEPDB1) is on Oracle Connector.

A VARCHAR2(4000) payload keeps the example free of LOBs. A CLOB payload needs lob.enabled=true on the Oracle connector, with the caveats about LOB handling described on the Oracle page and in Custom Converters & Post Processors.

PostgreSQL: an outbox without a table

PostgreSQL can write a message directly into the WAL with pg_logical_emit_message(), without any table. The PostgreSQL connector emits such messages as events with op: "m", and the DecodeLogicalDecodingMessageContent SMT turns their binary content into an insert-like event that the outbox router can process. Chain the two SMTs, decode first. Because no row is ever stored, there is nothing to clean up, but the message is only as durable as the WAL and the replication slot. The message events and the prefix filters are documented on PostgreSQL Connector, and the decoding SMT on Debezium Transformations.

MongoDB: the MongoDB outbox event router

The relational router does not work with the MongoDB connector. For MongoDB, Debezium provides io.debezium.connector.mongodb.transforms.outbox.MongoEventRouter, which reads an outbox collection. The writer must modify the business collection and insert the outbox document in one multi-document transaction (MongoDB 4.0 or later, on a replica set or sharded cluster). The expected document has the fields _id (ObjectId), aggregateid (ObjectId), aggregatetype, type and payload.

MongoDB outbox event router on bookshop-mongo-source
collection.include.list=bookshop.outbox
transforms=outbox
transforms.outbox.type=io.debezium.connector.mongodb.transforms.outbox.MongoEventRouter
transforms.outbox.collection.expand.json.payload=true
transforms.outbox.collection.fields.additional.placement=type:header:eventType
transforms.outbox.route.topic.replacement=outbox.event.${routedByValue}
value.converter=org.apache.kafka.connect.json.JsonConverter
value.converter.schemas.enable=false

The options mirror the relational ones with collection. in place of table.: collection.op.invalid.behavior, collection.field.event.id (default _id), collection.field.event.key (default aggregateid), collection.field.event.timestamp, collection.field.event.payload (default payload), collection.expand.json.payload, collection.fields.additional.placement, collection.field.additional.missing and collection.field.event.schema.version. The route.* and tracing.* options are the same as for the relational router.

The Debezium Outbox Quarkus extension

For Quarkus applications Debezium provides an extension that creates the outbox table and writes outbox rows for you. The application fires a CDI event that implements io.debezium.outbox.quarkus.ExportedEvent, and the extension persists it with Hibernate ORM inside the current transaction. The defaults of the extension match the defaults of the router, so the connector configuration above only needs the table name.

Version facts, checked on 2026-11-09:

  • Artifact io.debezium:debezium-quarkus-outbox:3.7.1.Final, and io.debezium:debezium-quarkus-outbox-reactive:3.7.1.Final for Hibernate Reactive.

  • The Debezium 3.7 release page lists Java 21+ for the Outbox and Quarkus extensions (connectors need Java 17+). The extension’s build sets the Java release to 21.

  • Debezium 3.7.1.Final builds the extension against Quarkus 3.33 (quarkus.version 3.33.1.1 in its parent POM). The current Quarkus release is 3.40.1 and Quarkus 4.0 is in beta. Align your Quarkus platform with a version the extension supports, and test before you move to a newer major Quarkus release.

Maven dependency for the Outbox Quarkus extension
<dependency>
  <groupId>io.debezium</groupId>
  <artifactId>debezium-quarkus-outbox</artifactId>
  <version>3.7.1.Final</version>
</dependency>

An OrderPlaced event for a Quarkus version of the order service. The type parameters are the aggregate id type and the payload type; every ExportedEvent implementation in one application must use the same ones, because they share one table.

OrderPlacedEvent implementing ExportedEvent
package com.example.bookshop.orders;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Map;
import java.util.UUID;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.debezium.outbox.quarkus.ExportedEvent;

public class OrderPlacedEvent implements ExportedEvent<String, JsonNode> {

    private static final ObjectMapper MAPPER = new ObjectMapper();

    private final UUID orderId;
    private final JsonNode payload;
    private final Instant timestamp;

    public OrderPlacedEvent(UUID orderId, UUID customerId, BigDecimal total, Instant placedAt) {
        this.orderId = orderId;
        this.timestamp = placedAt;
        ObjectNode node = MAPPER.createObjectNode();
        node.put("orderId", orderId.toString());
        node.put("customerId", customerId.toString());
        node.put("total", total);
        node.put("placedAt", placedAt.toString());
        this.payload = node;
    }

    @Override
    public String getAggregateId() {
        return orderId.toString(); // becomes the Kafka record key
    }

    @Override
    public String getAggregateType() {
        return "Order"; // becomes the topic suffix: outbox.event.Order
    }

    @Override
    public String getType() {
        return "OrderPlaced";
    }

    @Override
    public Instant getTimestamp() {
        return timestamp;
    }

    @Override
    public JsonNode getPayload() {
        return payload;
    }

    @Override
    public Map<String, Object> getAdditionalFieldValues() {
        return Map.of();
    }
}
OrderService firing the event inside the transaction
package com.example.bookshop.orders;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.UUID;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Event;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.transaction.Transactional;

import io.debezium.outbox.quarkus.ExportedEvent;

@ApplicationScoped
public class OrderService {

    @Inject
    EntityManager entityManager;

    @Inject
    Event<ExportedEvent<?, ?>> event;

    @Transactional
    public UUID placeOrder(UUID customerId, BigDecimal total) {
        UUID orderId = UUID.randomUUID();
        Instant placedAt = Instant.now();
        entityManager.createNativeQuery("""
                INSERT INTO purchase_order (id, customer_id, placed_at, status, total)
                VALUES (?1, ?2, ?3, 'NEW', ?4)""")
            .setParameter(1, orderId)
            .setParameter(2, customerId)
            .setParameter(3, placedAt)
            .setParameter(4, total)
            .executeUpdate();
        // The extension writes the outbox row in this same transaction
        event.fire(new OrderPlacedEvent(orderId, customerId, total, placedAt));
        return orderId;
    }
}

The official page still names javax.enterprise.event.Event in its prose; current Quarkus versions use the jakarta.* namespace, as above. The reactive variant provides a DebeziumOutboxHandler bean whose persistToOutbox(event) returns a Mutiny Uni that must be subscribed to, inside a @ReactiveTransactional method.

Extension configuration

The build-time properties name the table and its columns; change them only together with the router options.

application.properties for the Outbox Quarkus extension
# Build time: table and columns (the values shown are the defaults)
quarkus.debezium-outbox.table-name=OutboxEvent
quarkus.debezium-outbox.id.name=id
quarkus.debezium-outbox.aggregate-id.name=aggregateid
quarkus.debezium-outbox.aggregate-type.name=aggregatetype
quarkus.debezium-outbox.type.name=type
quarkus.debezium-outbox.timestamp.name=timestamp
quarkus.debezium-outbox.payload.name=payload
quarkus.debezium-outbox.payload.column-definition=VARCHAR(8000)

# Extra column, set from ExportedEvent#getAdditionalFieldValues()
quarkus.debezium-outbox.additional-fields=customer_name:string:varchar(100)

# Runtime: delete the row right after inserting it (default true); Debezium still sees the insert in the log
quarkus.debezium-outbox.remove-after-insert=true

The full list of build-time properties also covers each column’s column-definition and JPA converter, payload.type (a Hibernate user type), the tracing span column (tracing-span.name, default tracingspancontext) and additional-fields, whose entries have the form <field-name>:<field-java-type>[:<field-column-definition>[:<field-jpa-attribute-converter>]].

On PostgreSQL, Hibernate creates the default table name OutboxEvent unquoted, so the database name is outboxevent. The matching connector needs "table.include.list": "public.outboxevent". The payload column is VARCHAR(8000) by default, so keep table.expand.json.payload=true on the router to emit real JSON. Every additional-fields column you want in the message must also appear in table.fields.additional.placement, and with table.field.additional.missing=error the router fails if it does not.

What goes wrong

Symptom Cause and fix

Old events are published again after the connector is created or reset

The initial snapshot read the rows still in the outbox. Use snapshot.mode=no_data for outbox connectors, and delete processed rows.

Raw change events for business tables appear on outbox.event.* topics, or the task fails on them

The connector captures more than the outbox, and the router has no predicate. Restrict table.include.list, or add a TopicNameMatches predicate.

Warnings about UPDATE operations on the outbox table

Writer code updates outbox rows (for example to mark them as sent, a habit from a polling publisher). Remove the update; with CDC there is nothing to mark.

Events of one order arrive out of order

The key is not the aggregate id (wrong table.field.event.key), or the topic was repartitioned.

Consumers see an escaped JSON string

table.expand.json.payload is not set, or the value converter is not the JsonConverter.

Duplicate events after a restart

Expected with at-least-once delivery. De-duplicate on the id header in consumers (see the idempotent consumer on Transactional Outbox), or enable exactly-once source support where available (see Offsets, Restarts & Exactly-Once).

The outbox table grows without limit

Nothing deletes processed rows. Delete in the same transaction (as the Quarkus extension does) or periodically.

Verifying an outbox pipeline

  1. Call the writer (place an order) and check in PostgreSQL that the outbox row was committed with the order: SELECT id, aggregatetype, aggregateid, type FROM outbox_event ORDER BY created_at DESC LIMIT 1;

  2. Check the connector: GET http://localhost:8083/connectors/bookshop-pg-outbox/status must show the connector and its task as RUNNING.

  3. Read the topic with keys and headers, and compare the id header with the outbox row id.

  4. Roll back a transaction on purpose (for example, throw after the outbox insert in a test) and confirm that no message appears.

  5. Delete the outbox row and confirm that nothing new is published.

Reading the outbox topic with keys and headers
kafka-console-consumer.sh --bootstrap-server localhost:9092 \
  --topic outbox.event.Order --from-beginning \
  --formatter-property print.key=true --formatter-property print.headers=true

An automated version of these checks, with Testcontainers, is on Testing CDC Pipelines.