Skip to main content

Triggers

The ballerinax/oracledb connector supports event-driven integration through Change Data Capture (CDC) powered by Debezium's LogMiner-based Oracle connector. When rows are inserted, updated, deleted, or read during the initial snapshot in monitored Oracle tables, the oracledb:CdcListener receives change events in real time and invokes your service callbacks automatically.

Three components work together:

ComponentRole
oracledb:CdcListenerConnects to the Oracle database's redo/archive logs through LogMiner and streams row-level change events to attached services.
cdc:ServiceDefines the onRead, onCreate, onUpdate, onDelete, and onError callbacks invoked per change event.
OracleDatabaseConnectionConfiguration record for the Oracle CDC database connection (host, port, credentials, LogMiner and driver settings).

For action-based record operations, see the Action Reference.


Listener​

The oracledb:CdcListener establishes the connection and manages event subscriptions.

Configuration​

The listener supports the following connection strategies:

Config TypeDescription
OracleDatabaseConnectionConfigures the CDC database connection including server address, credentials, LogMiner tuning, and driver pass-through options.
OracleListenerConfigurationTop-level listener configuration wrapping the database connection and CDC options.

OracleDatabaseConnection fields:

FieldTypeDefaultDescription
connectorClassstring"io.debezium.connector.oracle.OracleConnector"The Debezium Oracle connector class name.
hostnamestring"localhost"The hostname of the Oracle server. Ignored when url is set.
portint1521The port number of the Oracle listener. Ignored when url is set.
databaseNamestringRequiredThe root container (CDB) name for multitenant Oracle, or the database name for legacy non-CDB Oracle.
urlstring?()Raw JDBC URL for TNS, RAC, or TCPS connections. Overrides hostname and port only.
pdbNamestring?()The pluggable database (PDB) name, for multitenant installations only.
adapterModeAdapterModeLOGMINERLogMiner buffering mode: connector-side (LOGMINER) or database-side (LOGMINER_UNBUFFERED).
racNodesstring|string[]?()RAC node list (host:port or host:port/SID). Required when connecting to an Oracle RAC cluster, even when url is set.
includedSchemasstring|string[]?()Regex patterns of schemas to capture. Mutually exclusive with excludedSchemas.
excludedSchemasstring|string[]?()Regex patterns of schemas to exclude. Mutually exclusive with includedSchemas.
includedTablesstring|string[]?()Regex patterns of schema-qualified table names to capture (for example, "APP_USER\\.CUSTOMERS"). Mutually exclusive with excludedTables.
excludedTablesstring|string[]?()Regex patterns of tables to exclude. Mutually exclusive with includedTables.
includedColumnsstring|string[]?()Regex patterns of columns to capture. Mutually exclusive with excludedColumns.
excludedColumnsstring|string[]?()Regex patterns of columns to exclude. Mutually exclusive with includedColumns.
logMinerConfigLogMinerConfiguration?()LogMiner adapter tunables. See Supporting types.
driverConfigDriverConfiguration?()Oracle JDBC driver pass-through configuration (mTLS, Oracle Wallet, timezone handling).
note

Unlike the MySQL and PostgreSQL connectors, OracleDatabaseConnection does not support the inherited secure field (cdc:SecureDatabaseConnection) — the Oracle connector does not read database.ssl.* properties, and setting secure raises a configuration error at listener initialization. Configure TLS through driverConfig.mtls instead, using either a Java keystore/truststore (DriverSslConfiguration) or an Oracle Wallet location string.

OracleListenerConfiguration fields:

FieldTypeDefaultDescription
databaseOracleDatabaseConnectionRequiredThe Oracle CDC database connection configuration.
optionsOracleOptions{}Oracle-specific CDC options including snapshot, LOB, streaming, and data type handling. See Supporting types.
engineNamestring"ballerina-cdc-connector"Debezium engine instance name. Inherited from cdc:ListenerConfiguration.
internalSchemaStoragecdc:InternalSchemaStorage{fileName: "tmp/dbhistory.dat"}Schema-history storage configuration (file, Kafka, JDBC, Redis, S3, Azure Blob, RocketMQ, or in-memory). Inherited from cdc:ListenerConfiguration.
offsetStoragecdc:OffsetStorage{fileName: "tmp/debezium-offsets.dat"}Offset storage configuration (file, Kafka, JDBC, Redis, or in-memory). Inherited from cdc:ListenerConfiguration.
livenessIntervaldecimal60.0Interval, in seconds, for checking CDC listener liveness. Inherited from cdc:ListenerConfiguration.

Initializing the listener​

Basic CDC listener with default settings:

import ballerinax/oracledb;
import ballerinax/oracledb.cdc.driver as _;

configurable string username = ?;
configurable string password = ?;
configurable string database = ?;

listener oracledb:CdcListener cdcListener = new (database = {
username: username,
password: password,
databaseName: database
});

CDC listener with LogMiner tuning and table filters:

import ballerinax/cdc;
import ballerinax/oracledb;
import ballerinax/oracledb.cdc.driver as _;

configurable string username = ?;
configurable string password = ?;
configurable string database = ?;

listener oracledb:CdcListener cdcListener = new (
database = {
username: username,
password: password,
databaseName: database,
pdbName: "FREEPDB1",
includedTables: "APP_USER\\.CUSTOMERS",
logMinerConfig: {
strategy: cdc:ONLINE_CATALOG
}
},
options = {
snapshotMode: cdc:NO_DATA,
skippedOperations: [cdc:UPDATE, cdc:DELETE]
}
);
note

includedTables, excludedTables, includedSchemas, and excludedSchemas are regular expressions, not literal names. Escape a literal . in a schema-qualified table name — for example, "APP_USER\\.CUSTOMERS" — otherwise the unescaped . matches any single character.


Service​

A cdc:Service is a Ballerina service attached to an oracledb:CdcListener. It listens for row-level change events on monitored Oracle tables and implements callbacks for each event type. You can type the callback parameters with your own Ballerina record types for automatic mapping.

Callback signatures​

FunctionSignatureDescription
onReadremote function onRead(record {} after) returns cdc:Error?Invoked during the initial snapshot for each existing row read from the database.
onCreateremote function onCreate(record {} after) returns cdc:Error?Invoked when a new row is inserted into a monitored table.
onUpdateremote function onUpdate(record {} before, record {} after) returns cdc:Error?Invoked when a row is updated, providing both the before and after state.
onDeleteremote function onDelete(record {} before) returns cdc:Error?Invoked when a row is deleted, providing the row state before deletion.
onErrorremote function onError(cdc:Error err) returns cdc:Error?Invoked when the listener encounters an error during change-event delivery (for example, deserialization failures or connector errors).
note

You do not need to implement all of these callbacks. Only implement the event types relevant to your use case.

tip

When a single listener captures multiple tables, add a trailing string tableName parameter to a callback (for example, onCreate(record {} after, string tableName)) to identify which table produced the event.

Full usage example​

import ballerina/log;
import ballerinax/cdc;
import ballerinax/oracledb;
import ballerinax/oracledb.cdc.driver as _;

configurable string username = ?;
configurable string password = ?;
configurable string database = ?;

type Order record {|
int ORDER_ID;
int CUSTOMER_ID;
decimal AMOUNT;
string STATUS;
|};

listener oracledb:CdcListener cdcListener = new (
database = {
username: username,
password: password,
databaseName: database,
pdbName: "FREEPDB1",
includedTables: "APP_USER\\.ORDERS"
},
options = {
snapshotMode: cdc:NO_DATA
}
);

service cdc:Service on cdcListener {
isolated remote function onRead(Order after) returns cdc:Error? {
log:printInfo("Snapshot row", 'order = after.toString());
}

isolated remote function onCreate(Order after) returns cdc:Error? {
log:printInfo("New order created",
orderId = after.ORDER_ID,
amount = after.AMOUNT
);
}

isolated remote function onUpdate(Order before, Order after) returns cdc:Error? {
log:printInfo("Order updated",
orderId = after.ORDER_ID,
oldStatus = before.STATUS,
newStatus = after.STATUS
);
}

isolated remote function onDelete(Order before) returns cdc:Error? {
log:printInfo("Order deleted", orderId = before.ORDER_ID);
}

isolated remote function onError(cdc:Error err) returns cdc:Error? {
log:printError("CDC error", 'error = err);
}
}
note

For CDC to work, the Oracle database must be in ARCHIVELOG mode with supplemental logging enabled, and the connecting user must hold LogMiner-related privileges. See the Setup Guide for the full set of steps.


Supporting types​

For the OracleDatabaseConnection field reference, see the Listener > Configuration section above.

AdapterMode​

LogMiner adapter mode for capturing changes from the Oracle database transaction logs.

ConstantValueDescription
LOGMINER"logminer"Connector-side LogMiner buffer (default).
LOGMINER_UNBUFFERED"logminer_unbuffered"Database-side LogMiner buffer; the database performs transaction buffering.

LogMinerConfiguration​

LogMiner adapter tunables. Applies to both LOGMINER and LOGMINER_UNBUFFERED adapter modes.

FieldTypeDefaultDescription
strategyLogMiningStrategyONLINE_CATALOGMining strategy used when reading redo/archive logs.
queryFilterModeLogMiningQueryFilterModeNONEHow table-include filters are applied to the LogMiner query (NONE, IN, REGEX).
readOnlyHostnamestring?()Hostname of a read-only standby to direct LogMiner queries at.
flushTableNamestring"LOG_MINING_FLUSH"Name of the internal flush table; useful for RAC deployments.
bufferLogMinerMemoryBufferConfiguration?()In-memory transaction buffer tunables.
sessionMaxDurationdecimal?()Max time before closing and reopening the LogMiner session, in seconds; no limit if not set.
restartConnectionbooleanfalseRestart the JDBC connection when a mining session is rotated.
batchLogMinerBatchConfiguration?()SCN-based mining batch sizing.
sleepLogMinerSleepConfiguration?()Sleep timing between mining iterations.
archiveLogMinerArchiveLogConfiguration?()Archive-log mining configuration.
transactionRetentionTimedecimal?()Time to retain transactions in the buffer before forced commit/rollback, in seconds.
maxWindowTimedecimal?()Max mining window duration in seconds before forced advance of the offset.
includedUsernamesstring|string[]?()Usernames whose changes to capture. Mutually exclusive with excludedUsernames.
excludedUsernamesstring|string[]?()Usernames whose changes to skip. Mutually exclusive with includedUsernames.
includedClientIdsstring|string[]?()JDBC client IDs whose changes to capture. Mutually exclusive with excludedClientIds.
excludedClientIdsstring|string[]?()JDBC client IDs whose changes to skip. Mutually exclusive with includedClientIds.
scnGapDetectionMinSizeint1000000Minimum SCN delta to consider for gap detection.
scnGapDetectionMaxIntervaldecimal20Max time window in seconds for the SCN gap detection heuristic.

LogMiningStrategy​

ConstantValueDescription
ONLINE_CATALOG"online_catalog"Always use the online data dictionary (lowest overhead, no schema-change support).
REDO_LOG_CATALOG"redo_log_catalog"Use the data dictionary written to the redo logs (supports schema changes).
HYBRID"hybrid"Hybrid approach combining online catalog with selective redo-log lookups. Incompatible with options.lobEnabled = true.

LogMinerMemoryBufferConfiguration​

FieldTypeDefaultDescription
trackRsIdbooleantrueTrack the row-id (RS_ID) of each event in the transaction buffer.
transactionEventsThresholdint?()Max events per transaction before abandoning the transaction.

LogMinerBatchConfiguration​

SCN-based LogMiner mining batch sizing. SCN is a monotonically increasing integer that Oracle stamps onto every committed change; Debezium uses it as its streaming offset.

FieldTypeDefaultDescription
minSizeint1000Minimum SCN window size.
maxSizeint100000Maximum SCN window size.
incrementSizeint20000Amount to grow/shrink the window when adapting.
defaultSizeint20000Initial/fallback SCN window size.

LogMinerSleepConfiguration​

Sleep timing between LogMiner mining iterations, in seconds.

FieldTypeDefaultDescription
minTimedecimal0Minimum sleep duration.
maxTimedecimal3Maximum sleep duration.
defaultTimedecimal1Initial/fallback sleep duration.
incrementTimedecimal0.2Amount to grow/shrink sleep when adapting.

LogMinerArchiveLogConfiguration​

FieldTypeDefaultDescription
logHoursint?()Number of hours of archive logs to scan for the start SCN. If not set, mines all archive logs.
destinationNamestring|string[]?()Configured Oracle archive destination(s) to use when mining archive logs.
logOnlyModebooleanfalseMine only archive logs, ignoring redo logs. Increases latency but improves reliability.
logOnlyScnPollIntervaldecimal10Poll interval in seconds when waiting for a new SCN. Applicable only when logOnlyMode is true.

OracleOptions​

Oracle-specific CDC options for snapshot, LOB capture, streaming, and data type handling. Extends cdc:Options.

FieldTypeDefaultDescription
extendedSnapshotOracleExtendedSnapshotConfiguration?()Snapshot config with Oracle-specific configuration-based sub-flags.
dataTypeConfigOracleDataTypeConfiguration?()Data type handling, including Oracle INTERVAL representation.
heartbeatConfigcdc:RelationalHeartbeatConfiguration?()Heartbeat configuration for keeping the connection alive.
streamingDelaydecimal?()Delay between snapshot completion and streaming start, in seconds.
queryFetchSizeint10000JDBC fetch size for streaming queries.
lobEnabledbooleanfalseEnable CLOB/NCLOB/BLOB/XML capture. Incompatible with the HYBRID mining strategy.
unavailableValuePlaceholderstring"__debezium_unavailable_value"Placeholder string emitted for unchanged LOB columns.
snapshotDatabaseErrorsMaxRetriesint0Per-table retry count for snapshot-time database errors (for example, ORA-01466).
snapshotModecdc:SnapshotModeINITIALInitial snapshot behavior. Inherited from cdc:Options.
skippedOperationscdc:Operation[][TRUNCATE]Operations to skip publishing (CREATE, UPDATE, DELETE, TRUNCATE). Inherited from cdc:Options.

OracleExtendedSnapshotConfiguration​

Extends cdc:RelationalExtendedSnapshotConfiguration with Oracle-specific configuration-based snapshot sub-flags.

FieldTypeDefaultDescription
configurationBasedConfigurationBasedSnapshot?()Sub-flags active only when snapshotMode == CONFIGURATION_BASED.

ConfigurationBasedSnapshot​

FieldTypeDefaultDescription
includeDatabooleanfalseInclude row data in the snapshot.
includeSchemabooleanfalseInclude schema (DDL) in the snapshot.
startStreambooleanfalseStart streaming after the snapshot completes.
snapshotOnSchemaErrorbooleanfalseRe-snapshot on schema error.
snapshotOnDataErrorbooleanfalseRe-snapshot on data error.

OracleDataTypeConfiguration​

Extends cdc:DataTypeConfiguration with Oracle-specific handling.

FieldTypeDefaultDescription
intervalHandlingModeIntervalHandlingModeNUMERICHow Oracle INTERVAL types are represented (numeric vs ISO-8601 string).

IntervalHandlingMode​

ConstantValueDescription
NUMERIC"numeric"Numeric representation (microseconds for day-second, months for year-month).
STRING"string"ISO-8601 string representation.

DriverConfiguration​

Oracle JDBC driver pass-through configuration. All values are emitted with the driver. prefix as Debezium pass-through properties.

FieldTypeDescription
mtlsDriverSslConfiguration|string?mTLS client authentication for Oracle — supply either a Java keystore/truststore (mapped to driver.javax.net.ssl.*) or an Oracle Wallet location string (mapped to driver.oracle.net.wallet_location). These are two alternative methods, not combinable.
timezoneAsRegionboolean?Whether the JDBC driver should resolve timezone as a region (driver.oracle.jdbc.timezoneAsRegion). Set to false to work around ORA-01882 ("timezone region not found").

DriverSslConfiguration​

FieldTypeDescription
keyStoreDriverKeyStore?Client keystore, mapped to driver.javax.net.ssl.keyStore*.
trustStoreDriverTrustStore?Server certificate truststore, mapped to driver.javax.net.ssl.trustStore*.

DriverKeyStore / DriverTrustStore​

FieldTypeDefaultDescription
pathstringRequiredFilesystem path to the keystore/truststore file.
passwordstringRequiredKeystore/truststore password.
storeTypeStoreTypeJKSStore format (JKS or PKCS12).