# Oracle XStream Source

> Stream committed row changes from Oracle Database into an Iggy stream through XStream Out, with at-least-once delivery.

Rendered page: https://iggy.apache.org/docs/connectors/sources/oracle_xstream/

Source: https://github.com/apache/iggy-connectors/blob/master/docs/sources/oracle_xstream.mdx

Docs version: the upcoming Apache Iggy release, from the master branches of apache/iggy and apache/iggy-connectors

The Oracle XStream source connector streams committed row changes (`INSERT`, `UPDATE`, `DELETE`) from Oracle Database into an Iggy stream. An XStream Out outbound server inside the database captures changes from the redo log, assembles whole transactions and delivers them in commit order. The connector is the client of that outbound server. Delivery is at-least-once: the connector tells Oracle that a change is processed only after the runtime has acknowledged the batch.

Target: Oracle 19c Enterprise Edition and later, multitenant (CDB) and non-CDB.

**Licence.** Oracle documents that the XStream APIs require a license for the Oracle GoldenGate product. Every user of this connector needs it. The Oracle client library is loaded at run time and is never redistributed with Iggy.

This page is a curated subset of the documentation. The canonical reference, including the database setup, is the [oracle_xstream_source README](https://github.com/apache/iggy-connectors/tree/master/sources/oracle_xstream_source) in the `apache/iggy-connectors` repository.

## Requirements

- An outbound server that a DBA created. The connector never runs DDL.
- Oracle Instant Client (Basic) on the host that runs the connectors runtime, and `libaio` on Linux.
- `DIAG_SIGHANDLER_ENABLED=FALSE` in the client's `sqlnet.ora`. Without it, the first OCI call installs signal handlers for `SIGINT`, `SIGQUIT`, `SIGILL`, `SIGTRAP`, `SIGABRT`, `SIGFPE`, `SIGXCPU`, `SIGXFSZ` and `SIGSYS` in the runtime process.
- The database in `ARCHIVELOG` mode, and supplemental logging on the captured tables (`ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS` for full before images on updates).
- An outbound server created with `include_ddl => TRUE`, so that DDL rules exist next to the DML rules. On the 19.3 database we tested, they also exist when the argument is left out.
- A schema rule on the outbound server if new tables must be captured. A table rule misses `CREATE TABLE` of new tables and stops following a renamed table.

## Configuration

Use the broker credentials and main runtime configuration from the [source guide](https://iggy.apache.org/docs/connectors/sources/source#configuration). Build the plugin from the checkout root:

```bash
cargo build --release -p iggy_connector_oracle_xstream_source
```

Save this entry in the runtime's connector directory. Create the stream and topic first, and fill in the connection and outbound server values. The runtime requires `persisted` durability on the topic. It creates a missing topic that way and refuses to start with a topic created with another durability, so create a topic ahead of time with `persisted`.

```toml
type = "source"
key = "oracle"
enabled = true
version = 0
name = "Oracle source"
path = "target/release/libiggy_connector_oracle_xstream_source"
plugin_config_format = "toml"

[[streams]]
stream = "oracle"
topic = "changes"
schema = "json"
partition_id = 0
batch_length = 1000
linger_time = "5ms"

[plugin_config]
connect_string = "dbhost:1521/ORCLCDB"
username = "c##xstrmadmin"
password = "change-me"
outbound_server = "IGGY_XOUT"
tables = ["APP.ORDERS"]
```

### Options

| Option | Type | Default | Description |
| ------ | ---- | ------- | ----------- |
| `connect_string` | string | **required** | Easy Connect string of the CDB root service |
| `username` | string | **required** | User that ran `CREATE_OUTBOUND` |
| `password` | string | **required** | Secret. Not logged |
| `outbound_server` | string | **required** | Outbound server name, at most 30 bytes |
| `oci_library_path` | string | platform default | Path of `libclntsh` |
| `tables` | list | all captured tables | `OWNER.TABLE` names or `OWNER.*`, which also covers tables created later. Write bare names: an entry with a quote is rejected. Names match without regard to case, so a table created with a quoted mixed-case name, such as `APP."Orders"`, and `APP.ORDERS` are not told apart |
| `poll_interval` | string | `100ms` | Pause after a poll that returned no changes. A poll that returned changes is followed by the next one at once |
| `poll_budget` | string | `500ms` | Time a poll may spend collecting a batch when the stream is busy, including time spent skipping rows of tables that are not captured. An idle receive blocks for about 2 seconds on Oracle 19c, which Oracle decides, regardless |
| `max_batch_events` | usize | `1000` | Changes (rows and schema changes) per batch |
| `reattach_backoff` | string | `5s` | Pause before re-attaching after a stale session, a database or outbound server that is down or restarting, or any other attach error |
| `max_reattach_attempts` | u32 | `5` | Attempt limit for re-attaching. When used up the connector stops. A rejected login (wrong password, locked or expired account) stops it at once. A receive that fails this many times in a row stops it too |
| `allow_position_reset` | bool | `false` | When the saved position is below the outbound server's processed low position (`ORA-21560`), stop with an error. When `true`, attach from the server's own position instead, which skips every change in between. The saved position stays until the next acknowledged commit replaces it |
| `verbose_logging` | bool | `false` | Log every batch |

## Messages

The connector produces one Iggy message per row change, in Oracle commit order within a partition. Set `partition_id = 0` on the stream, or use a topic with one partition: without it the runtime spreads messages over the partitions of an existing topic and the commit order is lost. The headers `table` and `op` carry the table name and the operation (`insert`, `update`, `delete` or `ddl`). Column values: `NUMBER` is a JSON number when it is an integer that fits 64 bits, or when its decimal text survives a round trip through a double, and otherwise a string with the exact decimal text, so a 38 digit value is never rounded. A JSON number beyond 2^53 is exact in the payload, but `JSON.parse` in JavaScript rounds it, so a consumer must use a lossless JSON parser or read such values as text. Character columns are strings. `DATE` is an ISO 8601 string without fractions. `TIMESTAMP` has nine fraction digits, and `TIMESTAMP WITH TIME ZONE` also carries its offset. `RAW` is base64. `BINARY_FLOAT` and `BINARY_DOUBLE` are numbers, except `NaN` and infinities, which are strings. A NULL is `null`.

```json
{
  "table": "APP.ORDERS",
  "source_database": "PDB1",
  "op": "update",
  "position": "00000000001934F7...",
  "xid": "10.25.831",
  "source_time": "2026-11-25T10:11:12",
  "before": {"ID": 7, "STATUS": "NEW"},
  "after": {"ID": 7, "STATUS": "SHIPPED"}
}
```

The message id is derived from the position of the change, which Oracle makes unique per change and keeps identical on every replay. A replay carries the same ids, also when `tables` or the outbound rules have changed in between. Row messages carry exactly the columns of their change record. Apply a schema change to the target when its message arrives.

`source_database` names the database that wrote the change. The `table` header and the `tables` filter do not carry it, so capture one PDB per outbound server. If the server sends a change from a second database, the connector delivers the commits read before it, then stops with an error that names both databases.

A header value is limited to 255 bytes, so a table name that long loses only its header, and the payload still names the table.

## Schema changes

A DDL statement on a captured table never stops the connector. `COMMENT`, `CREATE INDEX` and `GRANT OBJECT` are skipped. Everything else is forwarded in stream order as one message with `op` set to `ddl`, the Oracle `command` and the `statement` text, and without `before` or `after`. This covers `ALTER TABLE`, `CREATE TABLE`, `TRUNCATE TABLE`, `DROP TABLE` and `RENAME`. The consumer decides what to do with them.

Stopping on DDL is not offered, because Oracle replays the DDL record after a restart.

## Delivery and state

- A batch is staged until the runtime acknowledges it. On acknowledgement the connector saves its checkpoint and tells Oracle the processed low position, which lets the database purge redo it no longer needs.
- On a negative acknowledgement, the same batch is sent again from memory without detaching from the outbound server.
- A batch that fills in the middle of a transaction ends there. Its acknowledgement does not move the low position into the open transaction, so a crash replays that whole transaction.
- Unacknowledged transactions are replayed in full after a restart, a killed runtime or a lost session.
- Order is guaranteed for the first delivery only. After a negative acknowledgement that follows publication, a restart or a lost session, the connector sends commits again that may already be in the topic, behind later commits. The replayed messages carry the same message ids, so a consumer must deduplicate by message id and must not rely on arrival order for replayed changes.
- Do not set `exactly_once = true` on this source. The runtime then expects the plugin to reproduce the same messages from its saved state, and a replay of the connector can cut its batches differently, for example after a restart with another `max_batch_events`, `poll_budget` or `tables`. Use the message id for deduplication instead.
- If Oracle reports that the saved position is below its processed low position (`ORA-21560`), the changes in between are no longer available. The connector stops, unless `allow_position_reset` is `true`: it then attaches without a position and the outbound server picks its own start. The changes in between are not replayed.
- The runtime stops a source after 5 consecutive negative acknowledgements (the SDK default). Nothing is lost, because the position only moves on acknowledgement, so a restart replays the unacknowledged transactions.
- A checkpoint written for another outbound server fails the connector at start, and so does one with the same layout and another version number. A checkpoint that cannot be decoded also fails the start, unless `allow_position_reset` is `true`: the connector then starts from the outbound server's own position, which replays everything after its processed low position.
- The checkpoint also holds the source database of the first change. After a restart or a reconnect, a change from another database ends the stream with an error.

## Performance

Measured on Oracle 19c Enterprise in Docker on the same host as the connector, with small rows of about 10 columns. Your numbers will differ.

- The time from a commit to the message is a few seconds, 3.6 to 4.7 seconds in the measurement. Oracle's capture process sets it. The connector returns the batch about a millisecond after it reads the commit.
- A poll with no changes lasts about 2 seconds, the idle receive of Oracle. `OCI_ATTR_XSTREAM_IDLE_TIMEOUT` defaults to 1 second and a larger value only lengthens the wait, so the connector does not set it.
- The connector itself handled about 170,000 rows per second in batches of 1000 rows, so Oracle's capture speed is the limit. A larger `max_batch_events` saves one acknowledgement per batch, and `poll_interval` only applies after a poll that returned nothing.
- Rows of tables that `tables` excludes are skipped before their columns are decoded, so a large excluded transaction costs little.

## Limits

- `NUMBER`, `VARCHAR2`, `NVARCHAR2`, `CHAR`, `NCHAR`, `DATE`, `TIMESTAMP` and `TIMESTAMP WITH TIME ZONE`, `RAW`, `BINARY_FLOAT` and `BINARY_DOUBLE` are forwarded. A forwarded row with any other column type (LOB, `LONG`, `XMLType`, `INTERVAL`, `ROWID`, `TIMESTAMP WITH LOCAL TIME ZONE`) ends the poll there. The commits read before it are delivered and acknowledged, then the connector stops. The error that names the table and column is written to the connector log. The runtime reports only a generic stop reason. Oracle replays the stopped transaction from its redo, with the column still in it, so the connector cannot get past it by itself. Rows of tables excluded by `tables` are skipped and never stop the connector: list the tables you want without the offending one, then restart. A row LCR with a command other than `INSERT`, `UPDATE`, `DELETE` or `COMMIT` (for example `LOB WRITE`) is handled the same way. When a transaction spans several batches, the earlier batches have already been delivered.
- There is no initial snapshot. The stream starts at the outbound server's position.
- On shutdown the connector waits up to 30 seconds for a receive in progress. Each OCI call has a 10 second call timeout, so a receive on a connection that died without a reset fails with `ORA-03156` and the connector attaches again. The timeout is set after the login, so a connect to a host that does not answer is limited only by the network timeouts of the connector host. If a receive still does not end, close returns without detaching.
- Redo retention is set by the capture process, not by the connector. The connector moves the processed low position only on acknowledgement, so it stays put while the captured tables are quiet. On Oracle 19c, with quiet tables, the database kept every archived log from `FIRST_SCN` onward and followed the low position only after minutes (`APPLIED_SCN` lagged it). No extra retention from a stale low position was seen, but runs past `checkpoint_retention_time` (default 60 days) were not tested. Monitor `DBA_CAPTURE.REQUIRED_CHECKPOINT_SCN` and set `checkpoint_retention_time` to the retention you need.
- An excluded row can carry LOB data. Oracle requires all pending chunks of an LCR before the next LCR, so the connector reads them first, and a very large excluded LOB can keep the drain past `poll_budget` until the chunks end. Commits read before it are held back for that time.
- Not tested: Standard Edition 2, RAC, Data Guard and managed cloud databases.

## Known issues

These are planned for later PRs.

- Messages carry the `table` and `op` headers only. A sink that deduplicates has to read `xid` and `position` from the payload. Headers for both are planned.
- The payload has no commit SCN, only the opaque `position` of each row and the `xid`. A decoded `commit_scn` field is planned.
- The connector cannot route a change to a partition by table or primary key, because a produced message has no key or partition field in the connector SDK. Commit order holds only within one partition, so use `partition_id = 0`. Key routing needs an SDK change and is planned as a separate PR.
- SDK: when `open` fails, the SDK returns only a status code and drops the error, so the runtime logs a generic "Plugin initialization failed". The Oracle source logs the cause itself before it returns. A fix belongs in the connector SDK and affects every connector.
- Runtime: the plugin `open` and `close` calls run directly on a Tokio worker, so the Oracle login and retries on open and the up to 30 second wait on close hold that worker. A fix belongs in the runtime (`spawn_blocking`) and affects every connector.
- The runtime does not tell the plugin that `exactly_once` is on, so the Oracle source cannot refuse it. Do not set `exactly_once = true` on this source.
- An excluded row with LOB data is read through before the next row, which can run a drain past `poll_budget`. Oracle requires all pending chunks of an LCR first, so the connector has no way around it.
