Debezium DB2 Connector
Since Camel 3.17
Only consumer is supported
The Debezium db2 component is wrapper around Debezium using Debezium Engine, which enables Change Data Capture from db2 database using Debezium without the need for Kafka or Kafka Connect.
| Note on handling failures: per Debezium Embedded Engine documentation, the engines are actively recording source offsets and periodically flush these offsets to a persistent storage. Therefore, when the application is restarted or crashed, the engine will resume from the last recorded offset. This means that, at normal operation, your downstream routes will receive each event exactly once. However, in case of an application crash (not having a graceful shutdown), the application will resume from the last recorded offset, which may result in receiving duplicate events immediately after the restart. Therefore, your downstream routes should be tolerant enough of such a case and deduplicate events if needed. Before the engine starts polling, the consumer health check reports the configured initial state ( The consumer starts when the engine has started the connector tasks, which is before an initial snapshot is done, so a long snapshot does not delay the start. If the engine fails while it starts, for example because the connector cannot reach the database, the database is not set up for change data capture, or the offset store cannot be read, the consumer fails to start, and so does the route, with the error of Debezium as the cause. Debezium gives each task If the embedded engine stops with an error later, it is not restarted: the route stays started but receives no further events. The failure is reported to the consumer exception handler (with |
Maven users will need to add the following dependency to their pom.xml for this component.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-debezium-db2</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> URI format
debezium-db2:name[?options]
| The JDBC driver of Db2 is not included, as its license is not the Apache license. Add the dependency for The Camel CLI downloads the driver by itself when a route uses this component, and |
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Debezium DB2 Connector component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
Properties for the Debezium engine and connector that have no option of their own, such as the Kafka brokers of the KafkaOffsetBackingStore or single message transformations, for example additionalProperties.bootstrap.servers=localhost:9092. This is a multi-value option with prefix: additionalProperties. | Map | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
A shared configuration with the default connector options of all the endpoints of this component. Each endpoint uses a copy, which its own options override. | Db2ConnectorEmbeddedDebeziumConfiguration | ||
The converter class that Camel passes to Debezium as internal.key.converter. Debezium does not read this property: it always stores the keys of the offsets as JSON, so this option has no effect. | org.apache.kafka.connect.json.JsonConverter | String | |
The converter class that Camel passes to Debezium as internal.value.converter. Debezium does not read this property: it always stores the values of the offsets as JSON, so this option has no effect. | org.apache.kafka.connect.json.JsonConverter | String | |
The Java class that decides when the offsets are committed. It must implement io.debezium.engine.spi.OffsetCommitPolicy. The default PeriodicCommitOffsetPolicy commits every offsetFlushIntervalMs, and AlwaysCommitOffsetPolicy commits after each batch of events. | String | ||
How long to wait for the offsets to be written to the offset store before the commit is cancelled; the offsets are then committed in a later attempt. Camel passes it to Debezium as offset.flush.timeout.ms. The default is 5 seconds. | 5000 | long | |
How often the default periodic commit policy commits the offsets. The events processed since the last commit are sent again after a crash. The default is 1 minute. | 60000 | long | |
The Java class of the Kafka Connect OffsetBackingStore that stores the offsets (the position of the connector in the database log), so that a restarted consumer continues where it stopped. The default FileOffsetBackingStore writes them to the offsetStorageFileName file, KafkaOffsetBackingStore to the offsetStorageTopic topic, and MemoryOffsetBackingStore keeps them in memory only. | org.apache.kafka.connect.storage.FileOffsetBackingStore | String | |
The file that the FileOffsetBackingStore writes the offsets to. Required with the default offsetStorage: creating the endpoint fails when it is not set, or when its folder does not exist or cannot be written. | String | ||
The number of partitions of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore. | int | ||
The replication factor of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore. | int | ||
The Kafka topic that the KafkaOffsetBackingStore writes the offsets to. Required with that offsetStorage, together with offsetStoragePartitions, offsetStorageReplicationFactor and the Kafka brokers as additionalProperties.bootstrap.servers. | String | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
The name of the schema where CDC change tables are located; defaults to 'ASNCDC'. | ASNCDC | String | |
The name of the schema where CDC control structures are located; defaults to 'ASNCDC'. | ASNCDC | String | |
Regular expressions matching columns to exclude from change events. | String | ||
Regular expressions matching columns to include in change events. | String | ||
A comma-separated list of regular expressions matching fully-qualified names of columns that adds the columns original type and original length as parameters to the corresponding field schemas in the emitted change records. | String | ||
The maximum time in milliseconds to wait for connection validation to complete. Defaults to 60 seconds. | 1m | long | |
Optional list of custom converters that would be used instead of default ones. The converters are defined using '\{converter.prefix}.type' config option and configured using options '\{converter.prefix}.{option}'. | String | ||
A comma-separated list of key-value pairs that are appended to the MBean object name. Keys must be valid JMX ObjectName property keys. For example: k1=v1,k2=v2. | String | ||
Regular expression identifying configuration keys whose values should be masked. When set, this custom pattern replaces Debeziums default password masking pattern. | .*secret$|.*password$|.*sasl\.jaas\.config$|.*basic\.auth\.user\.info|.*registry\.auth\.client-secret|.*credentials\.json$|.*connectionstring$|.*connection\.string$ | String | |
The name of the database from which the connector should capture changes. | String | ||
A comma-separated list of regular expressions that match database names to be excluded from monitoring. | String | ||
Resolvable hostname or IP address of the database server. | String | ||
The databases for which changes are to be captured. | String | ||
Required Password of the database user to be used when connecting to the database. | String | ||
Port of the database server. | 50000 | int | |
Time to wait for a query to execute, given in milliseconds. Defaults to 600 seconds (600,000 ms); zero means there is no limit. | 10m | int | |
Name of the database user to be used when connecting to the database. | String | ||
A comma-separated list of regular expressions matching the database-specific data type names that adds the data type’s original type and original length as parameters to the corresponding field schemas in the emitted change records. | String | ||
Informs connector which Db2 implementation platform it is connected to. The default is 'LUW', which means Windows, UNIX, Linux. Using a value of 'Z' ensures that the Db2 for z/OS specific SQL statements are used. | LUW | String | |
Specify how DECIMAL and NUMERIC columns should be represented in change events, including: 'precise' (the default) uses java.math.BigDecimal to represent values, which are encoded in the change events using a binary representation and Kafka Connect’s 'org.apache.kafka.connect.data.Decimal' type; 'string' uses string to represent values; 'double' represents values using Java’s 'double', which may not offer the precision but will be far easier to use in consumers. | precise | String | |
The maximum number of retries on connection errors before failing (-1 = no limit, 0 = disabled, > 0 = num of retries). | -1 | int | |
Specify how failures during converting of event should be handled, including: 'fail' throw an exception that the column of event conversion is failed with unmatched schema type, causing the connector to be stopped. it could need schema recovery to covert successfully; 'warn' (the default) the value of column of event that conversion failed will be null and be logged with warn level; 'skip' the value of column of event that conversion failed will be null and be logged with debug level. | warn | String | |
Specify how failures during processing of events (i.e. when encountering a corrupted event) should be handled, including: 'fail' (the default) an exception indicating the problematic event and its position is raised, causing the connector to be stopped; 'warn' the problematic event and its position will be logged and the event will be skipped; 'ignore' the problematic event will be skipped. | fail | String | |
The maximum time in milliseconds to wait for task executor to shut down. | 4s | long | |
Enable/Disable Debezium context headers that provides essential metadata for tracking and identifying the source of CDC events in downstream processing systems. | true | boolean | |
Specify how field names should be adjusted for compatibility with the message converter used by the connector, including: 'avro' replaces the characters that cannot be used in the Avro type name with underscore; 'avro_unicode' replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java;'none' does not apply any adjustment (default). | none | String | |
Specify the action to take when a guardrail collections limit is exceeded: 'warn' (the default) logs a warning message and continues processing; 'fail' stops the connector with an error. | warn | String | |
The maximum number of collections or tables that can be captured by the connector. When this limit is exceeded, the action specified by 'guardrail.collections.limit.action' will be taken. Set to 0 to disable this guardrail. | 0 | int | |
Length of an interval in milli-seconds in in which the connector periodically sends heartbeat messages to a heartbeat topic. Use 0 to disable heartbeat messages. Disabled by default. | 0ms | int | |
The prefix that is used to name heartbeat topics.Defaults to __debezium-heartbeat. | __debezium-heartbeat | String | |
Whether the connector should publish changes in the database schema to a Kafka topic with the same name as the database server ID. Each schema change will be recorded using a key that contains the database name and whose value include logical description of the new schema and optionally the DDL statement(s). The default is 'true'. This is independent of how the connector internally records database schema history. | true | boolean | |
The maximum size of chunk (number of documents/rows) for incremental snapshotting. | 1024 | int | |
Specify the strategy used for watermarking during an incremental snapshot: 'insert_insert' both open and close signal is written into signal data collection (default); 'insert_delete' only open signal is written on signal data collection, the close will delete the relative open signal;. | INSERT_INSERT | String | |
When enabled, uses the legacy table-per-thread parallel snapshot algorithm. When set to false (the default), tables are split into chunks and processed across all snapshot threads, allowing for higher concurrency for snapshots. | false | boolean | |
Maximum size of each batch of source records. Defaults to 2048. | 2048 | int | |
Maximum size of the queue for change events read from the database log but not yet recorded or forwarded. Defaults to 8192, and should always be larger than the maximum batch size. | 8192 | int | |
Maximum size of the queue in bytes for change events read from the database log but not yet recorded or forwarded. Defaults to 0. Mean the feature is not enabled. | 0 | long | |
The fully-qualified class name of the storage implementation for schema metadata. The class must implement io.debezium.relational.TableMappingStorage of io.debezium.relational.TableSchema. Defaults to io.debezium.relational.ConcurrentMapTableMappingStorage for in-memory storage. | io.debezium.relational.ConcurrentMapTableMappingStorage | String | |
The fully-qualified class name of the storage implementation for table metadata. The class must implement io.debezium.relational.TableMappingStorage of io.debezium.relational.Table. Defaults to io.debezium.relational.ConcurrentMapTableMappingStorage for in-memory storage. | io.debezium.relational.ConcurrentMapTableMappingStorage | String | |
A semicolon-separated list of expressions that match fully-qualified tables and column(s) to be used as message key. Each expression must match the pattern '\{fully-qualified table name}:\{key columns}', where the table names could be defined as (DB_NAME.TABLE_NAME) or (SCHEMA_NAME.TABLE_NAME), depending on the specific connector, and the key columns are a comma-separated list of columns representing the custom key. For any table without an explicit key configuration the table’s primary key column(s) will be used as message key. Example: dbserver1.inventory.orderlines:orderId,orderLineId;dbserver1.inventory.orders:id. | String | ||
List of notification channels names that are enabled. | String | ||
When true, the SSRF guard permits notification URLs that resolve to loopback, site-local or link-local addresses (e.g. an in-cluster Service). Defaults to false so only public addresses are allowed. | false | boolean | |
Number of retries after the first failed HTTP notification delivery attempt. Terminal notifications (COMPLETED/ABORTED/SKIPPED) are always retried at least 3 times. | 2 | int | |
Connect and read timeout, in milliseconds, for HTTP notification delivery. | 5s | int | |
The URL to which notifications are POSTed as JSON. Required when 'http' is in the list of enabled channels. | String | ||
The name of the topic for the notifications. This is required in case 'sink' is in the list of enabled channels. | String | ||
Path to OpenLineage file configuration. See https://openlineage.io/docs/client/java/configuration. | ./openlineage.yml | String | |
The Kafka bootstrap server address used as input/output namespace/. | String | ||
Enable Debezium to emit data lineage metadata through OpenLineage API. | false | boolean | |
The job’s description emitted by Debezium. | Debezium change data capture job | String | |
The job’s namespace emitted by Debezium. | String | ||
The job’s owners emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2. | String | ||
The job’s tags emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2. | String | ||
Time to wait for new change events to appear after receiving no events, given in milliseconds. Defaults to 500 ms. Values will be capped at 5000 ms. | 500ms | long | |
Optional list of post processors. The processors are defined using '\{post.processor.prefix}.type' config option and configured using options '\{post.processor.prefix}.{option}'. | String | ||
Enables transaction metadata extraction together with event counting. | false | boolean | |
The maximum number of records that should be loaded into memory while streaming. A value of '0' uses the default JDBC fetch size. The default value is '10000'. | 10000 | int | |
Time to wait before restarting connector after retriable exception occurs. Defaults to 10000ms. | 10s | long | |
The name of the SchemaHistory class that should be used to store and recover database schema changes. The configuration properties for the history are prefixed with the 'schema.history.internal.' string. | io.debezium.storage.kafka.history.KafkaSchemaHistory | String | |
The path to the file that will be used to record the database schema history. | String | ||
Controls how Debezium deduplicates identical schema objects (tables, columns, attributes) in memory using an interner. | off | String | |
Controls the action Debezium will take when it meets a DDL statement in binlog, that it cannot parse.By default the connector will stop operating but by changing the setting it can ignore the statements which it cannot parse. If skipping is enabled then Debezium can miss metadata changes. | false | boolean | |
Controls what DDL will Debezium store in database schema history. By default (false) Debezium will store all incoming DDL statements. If set to true, then only DDL that manipulates a table from captured schema/database will be stored. | false | boolean | |
Controls what DDL will Debezium store in database schema history. By default (false) Debezium will store all incoming DDL statements. If set to true, then only DDL that manipulates a captured table will be stored. | false | boolean | |
Specify how schema names should be adjusted for compatibility with the message converter used by the connector, including: 'avro' replaces the characters that cannot be used in the Avro type name with underscore; 'avro_unicode' replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java;'none' does not apply any adjustment (default). | none | String | |
The name of the data collection that is used to send signals/commands to Debezium. For multi-partition mode connectors, multiple signal data collections can be specified as a comma-separated list. Signaling is disabled when not set. | String | ||
Duration to sleep for after encountering an error emitting a window event, given in milliseconds. Defaults to 10 seconds. | 10s | long | |
The maximum number of retries after encountering an error emitting a window event (-1 = no limit, 0 = disabled, > 0 = num of retries). Defaults to 0. | 0 | int | |
List of channels names that are enabled. Source channel is enabled by default. | source | String | |
Interval for looking for new signals in registered channels, given in milliseconds. Defaults to 5 seconds. | 5s | long | |
Enable to skip publishing messages when there is no change in included columns.This would essentially filter messages to be sent when there is no change in columns included as per column.include.list/column.exclude.list.For Postgres - this would require REPLICA IDENTITY of table to be FULL. | false | boolean | |
The comma-separated list of operations to skip during streaming, defined as: 'c' for inserts/create; 'u' for updates; 'd' for deletes, 't' for truncates, and 'none' to indicate nothing skipped. By default, only truncate operations will be skipped. | t | String | |
A delay period before a snapshot will begin, given in milliseconds. Defaults to 0 ms. | 0ms | long | |
The maximum number of records that should be loaded into memory while performing a snapshot. | int | ||
This setting must be set to specify a list of tables/collections whose snapshot must be taken on creating or restarting the connector. | String | ||
Controls which transaction isolation level is used and how long the connector locks the monitored tables. The default is 'repeatable_read', which means that repeatable read isolation level is used. In addition, exclusive locks are taken only during schema snapshot. Using a value of 'exclusive' ensures that the connector holds the exclusive lock (and thus prevents any reads and updates) for all monitored tables during the entire snapshot duration. In 'read_committed' mode no table locks or any long-lasting* row-level locks are acquired, but connector does not guarantee snapshot consistency.In 'read_uncommitted' mode neither table nor row-level locks are acquired, but connector does not guarantee snapshot consistency. | repeatable_read | String | |
Controls how the connector holds locks on tables while performing the schema snapshot when snapshot.isolation.mode is REPEATABLE_READ or EXCLUSIVE. The 'exclusive' which means the connector will hold a table lock for exclusive table access for just the initial portion of the snapshot while the database schemas and other metadata are being read. The remaining work in a snapshot involves selecting all rows from each table, and this is done using a flashback query that requires no locks. However, in some cases it may be desirable to avoid locks entirely which can be done by specifying 'none'. This mode is only safe to use if no schema changes are happening while the snapshot is taken. | exclusive | String | |
The maximum number of millis to wait for table locks at the beginning of a snapshot. If locks cannot be acquired in this time frame, the snapshot will be aborted. Defaults to 10 seconds. | 10s | long | |
The factor used to scale the number of snapshot chunks per table. The default behavior is to take 'row_count/snapshot.max.threads' to compute the number of rows per chunks. This may not be ideal for larger tables, and using the multiplier, the formula is adjusted to increase the number of chunks by using 'row_count/(snapshot.max.threads * snapshot.max.threads.multiplier). | 1 | int | |
The criteria for running a snapshot upon startup of the connector. Options include: 'initial' (the default) to specify the connector should run a snapshot only when no offsets are available for the logical server name; 'schema_only' to specify the connector should run a snapshot of the schema when no offsets are available for the logical server name. | initial | String | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not in case of error. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not in case of error. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the stream should start or not after snapshot. | false | boolean | |
When 'snapshot.mode' is set as custom, this setting must be set to specify a the name of the custom implementation provided in the 'name()' method. The implementations must implement the 'Snapshotter' interface and is called on each app boot to determine whether to do a snapshot. | String | ||
This property contains a comma-separated list of fully-qualified tables (DB_NAME.TABLE_NAME) or (SCHEMA_NAME.TABLE_NAME), depending on the specific connectors. Select statements for the individual tables are specified in further configuration properties, one for each table, identified by the id 'snapshot.select.statement.overrides.[DB_NAME].[TABLE_NAME]' or 'snapshot.select.statement.overrides.[SCHEMA_NAME].[TABLE_NAME]', respectively. The value of those properties is the select statement to use when retrieving data from the specific table during snapshotting. A possible use case for large append-only tables is setting a specific point where to start (resume) snapshotting, in case a previous snapshotting was interrupted. | String | ||
Controls the order in which tables are processed in the initial snapshot. A descending value will order the tables by row count descending. A ascending value will order the tables by row count ascending. A value of disabled (the default) will disable ordering by row count. | disabled | String | |
The name of the SourceInfoStructMaker class that returns SourceInfo schema and struct. | io.debezium.connector.db2.Db2SourceInfoStructMaker | String | |
Enable to collect various kind of statistics, like latencies in record processing, and derived data like quantiles. By default collecting statistics is enabled. | true | boolean | |
A delay period after the snapshot is completed and the streaming begins, given in milliseconds. Defaults to 0 ms. | 0ms | long | |
The maximum number of seconds for a streaming query to include that query’s result set, starting from the earliest row in this query. Used to limit the size of queries when the change table is large to avoid excessive resource usage. If 0, no timespan limit will apply. | 0 | int | |
A comma-separated list of regular expressions that match the fully-qualified names of tables to be excluded from monitoring. | String | ||
Flag specifying whether built-in tables should be ignored. | true | boolean | |
The tables for which changes are to be captured. | String | ||
Time, date, and timestamps can be represented with different kinds of precisions, including: 'adaptive' (the default) bases the precision of time, date, and timestamp values on the database column’s precision; 'adaptive_time_microseconds' like 'adaptive' mode, but TIME fields always use microseconds precision; 'connect' always represents time, date, and timestamp values using Kafka Connect’s built-in representations for Time, Date, and Timestamp, which uses millisecond precision regardless of the database columns' precision; 'isostring' represents time, date, and timestamp values as ISO-8601 formatted strings at the UTC time zone; 'structured' represents time, date, timestamp, and datetime values as Kafka Connect structs with separate calendar and clock components; 'microseconds' always represents time, date, and timestamp values using microsecond precision; 'nanoseconds' always represents time, date, and timestamp values using nanosecond precision. | adaptive | String | |
Whether delete operations should be represented by a delete event and a subsequent tombstone event (true) or only by a delete event (false). Emitting the tombstone event (the default behavior) allows Kafka to completely delete all events pertaining to the given key once the source record got deleted. | false | boolean | |
The name of the TopicNamingStrategy class that should be used to determine the topic name for data change, schema change, transaction, heartbeat event etc. | io.debezium.schema.SchemaTopicNamingStrategy | String | |
Required Topic prefix that identifies and provides a namespace for the particular database server/cluster is capturing changes. The topic prefix should be unique across all other connectors, since it is used as a prefix for all Kafka topic names that receive events emitted by this connector. Only alphanumeric characters, hyphens, dots and underscores must be accepted. | String | ||
Class to make transaction context & transaction struct/schemas. | io.debezium.pipeline.txmetadata.DefaultTransactionMetadataFactory | String | |
The apply_qual name that represents the apply agent (this instance) to the subscription set. | String | ||
A switch to control if the connector instance is responsible for updating the prune table (usually done by IBM Apply agent) which will cause the IBM Capture agent to prune read data from the change tables. default false. | false | boolean | |
An switch to decrement the prune lsn/syncpoint by one to avoid allowing the last lsn processed to get pruned to avoid the risk of an unnecessary snapshot due to the last processed lsn not being present in the change table. | true | boolean | |
The minimum number of milliseconds between the connector instance’s update of the prune point for the subscription set. Default is 10000 (10 seconds). | 10s | int | |
The name of a prepared statement in the database that will be used instead of direct sql to allow for DBA control of the update code where needed. | String | ||
If set to update the prune table, this will identify the prune set name that should be used when updating the table for this instance. | String | ||
The target_server name that represents the apply agent’s target (where the data is going) for the subscription set. | String | ||
If true, causes the connector to ignore the stop LSN value from the IBMSNAP_REGISTER.CD_OLD_SYNCHPOINT column when polling. Apply this if events are getting dropped due to the stop LSN being smaller than the current range of LSNs. Only applies to z/OS platform. | false | boolean |
Endpoint Options
The Debezium DB2 Connector endpoint is configured using URI syntax:
debezium-db2:name
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Properties for the Debezium engine and connector that have no option of their own, such as the Kafka brokers of the KafkaOffsetBackingStore or single message transformations, for example additionalProperties.bootstrap.servers=localhost:9092. This is a multi-value option with prefix: additionalProperties. | Map | ||
The converter class that Camel passes to Debezium as internal.key.converter. Debezium does not read this property: it always stores the keys of the offsets as JSON, so this option has no effect. | org.apache.kafka.connect.json.JsonConverter | String | |
The converter class that Camel passes to Debezium as internal.value.converter. Debezium does not read this property: it always stores the values of the offsets as JSON, so this option has no effect. | org.apache.kafka.connect.json.JsonConverter | String | |
The Java class that decides when the offsets are committed. It must implement io.debezium.engine.spi.OffsetCommitPolicy. The default PeriodicCommitOffsetPolicy commits every offsetFlushIntervalMs, and AlwaysCommitOffsetPolicy commits after each batch of events. | String | ||
How long to wait for the offsets to be written to the offset store before the commit is cancelled; the offsets are then committed in a later attempt. Camel passes it to Debezium as offset.flush.timeout.ms. The default is 5 seconds. | 5000 | long | |
How often the default periodic commit policy commits the offsets. The events processed since the last commit are sent again after a crash. The default is 1 minute. | 60000 | long | |
The Java class of the Kafka Connect OffsetBackingStore that stores the offsets (the position of the connector in the database log), so that a restarted consumer continues where it stopped. The default FileOffsetBackingStore writes them to the offsetStorageFileName file, KafkaOffsetBackingStore to the offsetStorageTopic topic, and MemoryOffsetBackingStore keeps them in memory only. | org.apache.kafka.connect.storage.FileOffsetBackingStore | String | |
The file that the FileOffsetBackingStore writes the offsets to. Required with the default offsetStorage: creating the endpoint fails when it is not set, or when its folder does not exist or cannot be written. | String | ||
The number of partitions of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore. | int | ||
The replication factor of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore. | int | ||
The Kafka topic that the KafkaOffsetBackingStore writes the offsets to. Required with that offsetStorage, together with offsetStoragePartitions, offsetStorageReplicationFactor and the Kafka brokers as additionalProperties.bootstrap.servers. | String | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
The name of the schema where CDC change tables are located; defaults to 'ASNCDC'. | ASNCDC | String | |
The name of the schema where CDC control structures are located; defaults to 'ASNCDC'. | ASNCDC | String | |
Regular expressions matching columns to exclude from change events. | String | ||
Regular expressions matching columns to include in change events. | String | ||
A comma-separated list of regular expressions matching fully-qualified names of columns that adds the columns original type and original length as parameters to the corresponding field schemas in the emitted change records. | String | ||
The maximum time in milliseconds to wait for connection validation to complete. Defaults to 60 seconds. | 1m | long | |
Optional list of custom converters that would be used instead of default ones. The converters are defined using '\{converter.prefix}.type' config option and configured using options '\{converter.prefix}.{option}'. | String | ||
A comma-separated list of key-value pairs that are appended to the MBean object name. Keys must be valid JMX ObjectName property keys. For example: k1=v1,k2=v2. | String | ||
Regular expression identifying configuration keys whose values should be masked. When set, this custom pattern replaces Debeziums default password masking pattern. | .*secret$|.*password$|.*sasl\.jaas\.config$|.*basic\.auth\.user\.info|.*registry\.auth\.client-secret|.*credentials\.json$|.*connectionstring$|.*connection\.string$ | String | |
The name of the database from which the connector should capture changes. | String | ||
A comma-separated list of regular expressions that match database names to be excluded from monitoring. | String | ||
Resolvable hostname or IP address of the database server. | String | ||
The databases for which changes are to be captured. | String | ||
Required Password of the database user to be used when connecting to the database. | String | ||
Port of the database server. | 50000 | int | |
Time to wait for a query to execute, given in milliseconds. Defaults to 600 seconds (600,000 ms); zero means there is no limit. | 10m | int | |
Name of the database user to be used when connecting to the database. | String | ||
A comma-separated list of regular expressions matching the database-specific data type names that adds the data type’s original type and original length as parameters to the corresponding field schemas in the emitted change records. | String | ||
Informs connector which Db2 implementation platform it is connected to. The default is 'LUW', which means Windows, UNIX, Linux. Using a value of 'Z' ensures that the Db2 for z/OS specific SQL statements are used. | LUW | String | |
Specify how DECIMAL and NUMERIC columns should be represented in change events, including: 'precise' (the default) uses java.math.BigDecimal to represent values, which are encoded in the change events using a binary representation and Kafka Connect’s 'org.apache.kafka.connect.data.Decimal' type; 'string' uses string to represent values; 'double' represents values using Java’s 'double', which may not offer the precision but will be far easier to use in consumers. | precise | String | |
The maximum number of retries on connection errors before failing (-1 = no limit, 0 = disabled, > 0 = num of retries). | -1 | int | |
Specify how failures during converting of event should be handled, including: 'fail' throw an exception that the column of event conversion is failed with unmatched schema type, causing the connector to be stopped. it could need schema recovery to covert successfully; 'warn' (the default) the value of column of event that conversion failed will be null and be logged with warn level; 'skip' the value of column of event that conversion failed will be null and be logged with debug level. | warn | String | |
Specify how failures during processing of events (i.e. when encountering a corrupted event) should be handled, including: 'fail' (the default) an exception indicating the problematic event and its position is raised, causing the connector to be stopped; 'warn' the problematic event and its position will be logged and the event will be skipped; 'ignore' the problematic event will be skipped. | fail | String | |
The maximum time in milliseconds to wait for task executor to shut down. | 4s | long | |
Enable/Disable Debezium context headers that provides essential metadata for tracking and identifying the source of CDC events in downstream processing systems. | true | boolean | |
Specify how field names should be adjusted for compatibility with the message converter used by the connector, including: 'avro' replaces the characters that cannot be used in the Avro type name with underscore; 'avro_unicode' replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java;'none' does not apply any adjustment (default). | none | String | |
Specify the action to take when a guardrail collections limit is exceeded: 'warn' (the default) logs a warning message and continues processing; 'fail' stops the connector with an error. | warn | String | |
The maximum number of collections or tables that can be captured by the connector. When this limit is exceeded, the action specified by 'guardrail.collections.limit.action' will be taken. Set to 0 to disable this guardrail. | 0 | int | |
Length of an interval in milli-seconds in in which the connector periodically sends heartbeat messages to a heartbeat topic. Use 0 to disable heartbeat messages. Disabled by default. | 0ms | int | |
The prefix that is used to name heartbeat topics.Defaults to __debezium-heartbeat. | __debezium-heartbeat | String | |
Whether the connector should publish changes in the database schema to a Kafka topic with the same name as the database server ID. Each schema change will be recorded using a key that contains the database name and whose value include logical description of the new schema and optionally the DDL statement(s). The default is 'true'. This is independent of how the connector internally records database schema history. | true | boolean | |
The maximum size of chunk (number of documents/rows) for incremental snapshotting. | 1024 | int | |
Specify the strategy used for watermarking during an incremental snapshot: 'insert_insert' both open and close signal is written into signal data collection (default); 'insert_delete' only open signal is written on signal data collection, the close will delete the relative open signal;. | INSERT_INSERT | String | |
When enabled, uses the legacy table-per-thread parallel snapshot algorithm. When set to false (the default), tables are split into chunks and processed across all snapshot threads, allowing for higher concurrency for snapshots. | false | boolean | |
Maximum size of each batch of source records. Defaults to 2048. | 2048 | int | |
Maximum size of the queue for change events read from the database log but not yet recorded or forwarded. Defaults to 8192, and should always be larger than the maximum batch size. | 8192 | int | |
Maximum size of the queue in bytes for change events read from the database log but not yet recorded or forwarded. Defaults to 0. Mean the feature is not enabled. | 0 | long | |
The fully-qualified class name of the storage implementation for schema metadata. The class must implement io.debezium.relational.TableMappingStorage of io.debezium.relational.TableSchema. Defaults to io.debezium.relational.ConcurrentMapTableMappingStorage for in-memory storage. | io.debezium.relational.ConcurrentMapTableMappingStorage | String | |
The fully-qualified class name of the storage implementation for table metadata. The class must implement io.debezium.relational.TableMappingStorage of io.debezium.relational.Table. Defaults to io.debezium.relational.ConcurrentMapTableMappingStorage for in-memory storage. | io.debezium.relational.ConcurrentMapTableMappingStorage | String | |
A semicolon-separated list of expressions that match fully-qualified tables and column(s) to be used as message key. Each expression must match the pattern '\{fully-qualified table name}:\{key columns}', where the table names could be defined as (DB_NAME.TABLE_NAME) or (SCHEMA_NAME.TABLE_NAME), depending on the specific connector, and the key columns are a comma-separated list of columns representing the custom key. For any table without an explicit key configuration the table’s primary key column(s) will be used as message key. Example: dbserver1.inventory.orderlines:orderId,orderLineId;dbserver1.inventory.orders:id. | String | ||
List of notification channels names that are enabled. | String | ||
When true, the SSRF guard permits notification URLs that resolve to loopback, site-local or link-local addresses (e.g. an in-cluster Service). Defaults to false so only public addresses are allowed. | false | boolean | |
Number of retries after the first failed HTTP notification delivery attempt. Terminal notifications (COMPLETED/ABORTED/SKIPPED) are always retried at least 3 times. | 2 | int | |
Connect and read timeout, in milliseconds, for HTTP notification delivery. | 5s | int | |
The URL to which notifications are POSTed as JSON. Required when 'http' is in the list of enabled channels. | String | ||
The name of the topic for the notifications. This is required in case 'sink' is in the list of enabled channels. | String | ||
Path to OpenLineage file configuration. See https://openlineage.io/docs/client/java/configuration. | ./openlineage.yml | String | |
The Kafka bootstrap server address used as input/output namespace/. | String | ||
Enable Debezium to emit data lineage metadata through OpenLineage API. | false | boolean | |
The job’s description emitted by Debezium. | Debezium change data capture job | String | |
The job’s namespace emitted by Debezium. | String | ||
The job’s owners emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2. | String | ||
The job’s tags emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2. | String | ||
Time to wait for new change events to appear after receiving no events, given in milliseconds. Defaults to 500 ms. Values will be capped at 5000 ms. | 500ms | long | |
Optional list of post processors. The processors are defined using '\{post.processor.prefix}.type' config option and configured using options '\{post.processor.prefix}.{option}'. | String | ||
Enables transaction metadata extraction together with event counting. | false | boolean | |
The maximum number of records that should be loaded into memory while streaming. A value of '0' uses the default JDBC fetch size. The default value is '10000'. | 10000 | int | |
Time to wait before restarting connector after retriable exception occurs. Defaults to 10000ms. | 10s | long | |
The name of the SchemaHistory class that should be used to store and recover database schema changes. The configuration properties for the history are prefixed with the 'schema.history.internal.' string. | io.debezium.storage.kafka.history.KafkaSchemaHistory | String | |
The path to the file that will be used to record the database schema history. | String | ||
Controls how Debezium deduplicates identical schema objects (tables, columns, attributes) in memory using an interner. | off | String | |
Controls the action Debezium will take when it meets a DDL statement in binlog, that it cannot parse.By default the connector will stop operating but by changing the setting it can ignore the statements which it cannot parse. If skipping is enabled then Debezium can miss metadata changes. | false | boolean | |
Controls what DDL will Debezium store in database schema history. By default (false) Debezium will store all incoming DDL statements. If set to true, then only DDL that manipulates a table from captured schema/database will be stored. | false | boolean | |
Controls what DDL will Debezium store in database schema history. By default (false) Debezium will store all incoming DDL statements. If set to true, then only DDL that manipulates a captured table will be stored. | false | boolean | |
Specify how schema names should be adjusted for compatibility with the message converter used by the connector, including: 'avro' replaces the characters that cannot be used in the Avro type name with underscore; 'avro_unicode' replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java;'none' does not apply any adjustment (default). | none | String | |
The name of the data collection that is used to send signals/commands to Debezium. For multi-partition mode connectors, multiple signal data collections can be specified as a comma-separated list. Signaling is disabled when not set. | String | ||
Duration to sleep for after encountering an error emitting a window event, given in milliseconds. Defaults to 10 seconds. | 10s | long | |
The maximum number of retries after encountering an error emitting a window event (-1 = no limit, 0 = disabled, > 0 = num of retries). Defaults to 0. | 0 | int | |
List of channels names that are enabled. Source channel is enabled by default. | source | String | |
Interval for looking for new signals in registered channels, given in milliseconds. Defaults to 5 seconds. | 5s | long | |
Enable to skip publishing messages when there is no change in included columns.This would essentially filter messages to be sent when there is no change in columns included as per column.include.list/column.exclude.list.For Postgres - this would require REPLICA IDENTITY of table to be FULL. | false | boolean | |
The comma-separated list of operations to skip during streaming, defined as: 'c' for inserts/create; 'u' for updates; 'd' for deletes, 't' for truncates, and 'none' to indicate nothing skipped. By default, only truncate operations will be skipped. | t | String | |
A delay period before a snapshot will begin, given in milliseconds. Defaults to 0 ms. | 0ms | long | |
The maximum number of records that should be loaded into memory while performing a snapshot. | int | ||
This setting must be set to specify a list of tables/collections whose snapshot must be taken on creating or restarting the connector. | String | ||
Controls which transaction isolation level is used and how long the connector locks the monitored tables. The default is 'repeatable_read', which means that repeatable read isolation level is used. In addition, exclusive locks are taken only during schema snapshot. Using a value of 'exclusive' ensures that the connector holds the exclusive lock (and thus prevents any reads and updates) for all monitored tables during the entire snapshot duration. In 'read_committed' mode no table locks or any long-lasting* row-level locks are acquired, but connector does not guarantee snapshot consistency.In 'read_uncommitted' mode neither table nor row-level locks are acquired, but connector does not guarantee snapshot consistency. | repeatable_read | String | |
Controls how the connector holds locks on tables while performing the schema snapshot when snapshot.isolation.mode is REPEATABLE_READ or EXCLUSIVE. The 'exclusive' which means the connector will hold a table lock for exclusive table access for just the initial portion of the snapshot while the database schemas and other metadata are being read. The remaining work in a snapshot involves selecting all rows from each table, and this is done using a flashback query that requires no locks. However, in some cases it may be desirable to avoid locks entirely which can be done by specifying 'none'. This mode is only safe to use if no schema changes are happening while the snapshot is taken. | exclusive | String | |
The maximum number of millis to wait for table locks at the beginning of a snapshot. If locks cannot be acquired in this time frame, the snapshot will be aborted. Defaults to 10 seconds. | 10s | long | |
The factor used to scale the number of snapshot chunks per table. The default behavior is to take 'row_count/snapshot.max.threads' to compute the number of rows per chunks. This may not be ideal for larger tables, and using the multiplier, the formula is adjusted to increase the number of chunks by using 'row_count/(snapshot.max.threads * snapshot.max.threads.multiplier). | 1 | int | |
The criteria for running a snapshot upon startup of the connector. Options include: 'initial' (the default) to specify the connector should run a snapshot only when no offsets are available for the logical server name; 'schema_only' to specify the connector should run a snapshot of the schema when no offsets are available for the logical server name. | initial | String | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not in case of error. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not in case of error. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not. | false | boolean | |
When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the stream should start or not after snapshot. | false | boolean | |
When 'snapshot.mode' is set as custom, this setting must be set to specify a the name of the custom implementation provided in the 'name()' method. The implementations must implement the 'Snapshotter' interface and is called on each app boot to determine whether to do a snapshot. | String | ||
This property contains a comma-separated list of fully-qualified tables (DB_NAME.TABLE_NAME) or (SCHEMA_NAME.TABLE_NAME), depending on the specific connectors. Select statements for the individual tables are specified in further configuration properties, one for each table, identified by the id 'snapshot.select.statement.overrides.[DB_NAME].[TABLE_NAME]' or 'snapshot.select.statement.overrides.[SCHEMA_NAME].[TABLE_NAME]', respectively. The value of those properties is the select statement to use when retrieving data from the specific table during snapshotting. A possible use case for large append-only tables is setting a specific point where to start (resume) snapshotting, in case a previous snapshotting was interrupted. | String | ||
Controls the order in which tables are processed in the initial snapshot. A descending value will order the tables by row count descending. A ascending value will order the tables by row count ascending. A value of disabled (the default) will disable ordering by row count. | disabled | String | |
The name of the SourceInfoStructMaker class that returns SourceInfo schema and struct. | io.debezium.connector.db2.Db2SourceInfoStructMaker | String | |
Enable to collect various kind of statistics, like latencies in record processing, and derived data like quantiles. By default collecting statistics is enabled. | true | boolean | |
A delay period after the snapshot is completed and the streaming begins, given in milliseconds. Defaults to 0 ms. | 0ms | long | |
The maximum number of seconds for a streaming query to include that query’s result set, starting from the earliest row in this query. Used to limit the size of queries when the change table is large to avoid excessive resource usage. If 0, no timespan limit will apply. | 0 | int | |
A comma-separated list of regular expressions that match the fully-qualified names of tables to be excluded from monitoring. | String | ||
Flag specifying whether built-in tables should be ignored. | true | boolean | |
The tables for which changes are to be captured. | String | ||
Time, date, and timestamps can be represented with different kinds of precisions, including: 'adaptive' (the default) bases the precision of time, date, and timestamp values on the database column’s precision; 'adaptive_time_microseconds' like 'adaptive' mode, but TIME fields always use microseconds precision; 'connect' always represents time, date, and timestamp values using Kafka Connect’s built-in representations for Time, Date, and Timestamp, which uses millisecond precision regardless of the database columns' precision; 'isostring' represents time, date, and timestamp values as ISO-8601 formatted strings at the UTC time zone; 'structured' represents time, date, timestamp, and datetime values as Kafka Connect structs with separate calendar and clock components; 'microseconds' always represents time, date, and timestamp values using microsecond precision; 'nanoseconds' always represents time, date, and timestamp values using nanosecond precision. | adaptive | String | |
Whether delete operations should be represented by a delete event and a subsequent tombstone event (true) or only by a delete event (false). Emitting the tombstone event (the default behavior) allows Kafka to completely delete all events pertaining to the given key once the source record got deleted. | false | boolean | |
The name of the TopicNamingStrategy class that should be used to determine the topic name for data change, schema change, transaction, heartbeat event etc. | io.debezium.schema.SchemaTopicNamingStrategy | String | |
Required Topic prefix that identifies and provides a namespace for the particular database server/cluster is capturing changes. The topic prefix should be unique across all other connectors, since it is used as a prefix for all Kafka topic names that receive events emitted by this connector. Only alphanumeric characters, hyphens, dots and underscores must be accepted. | String | ||
Class to make transaction context & transaction struct/schemas. | io.debezium.pipeline.txmetadata.DefaultTransactionMetadataFactory | String | |
The apply_qual name that represents the apply agent (this instance) to the subscription set. | String | ||
A switch to control if the connector instance is responsible for updating the prune table (usually done by IBM Apply agent) which will cause the IBM Capture agent to prune read data from the change tables. default false. | false | boolean | |
An switch to decrement the prune lsn/syncpoint by one to avoid allowing the last lsn processed to get pruned to avoid the risk of an unnecessary snapshot due to the last processed lsn not being present in the change table. | true | boolean | |
The minimum number of milliseconds between the connector instance’s update of the prune point for the subscription set. Default is 10000 (10 seconds). | 10s | int | |
The name of a prepared statement in the database that will be used instead of direct sql to allow for DBA control of the update code where needed. | String | ||
If set to update the prune table, this will identify the prune set name that should be used when updating the table for this instance. | String | ||
The target_server name that represents the apply agent’s target (where the data is going) for the subscription set. | String | ||
If true, causes the connector to ignore the stop LSN value from the IBMSNAP_REGISTER.CD_OLD_SYNCHPOINT column when polling. Apply this if events are getting dropped due to the stop LSN being smaller than the current range of LSNs. Only applies to z/OS platform. | false | boolean |
Message Headers
The Debezium DB2 Connector component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelDebeziumSourceMetadata (consumer) Constant: | The source block of the change event as a Map: the connector name, the database, schema and table names, the position in the database log, and so on. Its fields depend on the connector, see the Debezium documentation of the connector. | Map | |
CamelDebeziumIdentifier (consumer) Constant: | The Kafka topic name that Debezium gives the event: for a row change the topic prefix, the database or schema name and the table name, for example dbserver1.inventory.customers. | String | |
| Constant: | The key of the event as a Kafka Connect Struct, usually the primary key columns of the row. Null for a table without a primary key. | Struct | |
CamelDebeziumOperation (consumer) Constant: | The operation of the change event: c for create (insert), u for update, d for delete, r for a read of a snapshot, and t (truncate) or m (message) on the connectors that send them. Not set for an event without an operation, such as a schema change event. | String | |
CamelDebeziumTimestamp (consumer) Constant: | The time in milliseconds since the epoch at which the connector processed the event, from the system clock of its JVM (the ts_ms field of the event). Also set as the CamelMessageTimestamp header. | Long | |
CamelDebeziumBefore (consumer) Constant: | The row before the change as a Kafka Connect Struct, for an update or a delete when the connector provides it. Null for an insert and a snapshot read. | Struct | |
CamelDebeziumDdlSQL (consumer) Constant: | The DDL statement of a schema change event. Not set for a row change. | String |
Message Body
The message body at each side of the Debezium DB2 Connector component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Consumer |
| The row after the change as a Kafka Connect Struct, which converts to a Map: convert it before a marshal, as its toString is not JSON. No body for a delete, a tombstone or a schema change event; the operation, the key, the row before the change and the DDL are in headers. Not known when |
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Usage
Message body
If the message body is not null (in case of tombstones), it contains the state of the row after the event occurred. It is one of two formats:
-
Struct -
Map(if you use the included Type Converter fromStructtoMap)
With the Debezium ExtractNewRecordState single message transformation (additionalProperties.transforms=unwrap and additionalProperties.transforms.unwrap.type=io.debezium.transforms.ExtractNewRecordState), the event is flattened to the row, and the body is that row as a Struct. The CamelDebeziumOperation header is then set only when the transformation adds the operation, with additionalProperties.transforms.unwrap.add.fields=op or additionalProperties.transforms.unwrap.add.headers=op (with the default __ prefix).
See below for more details.
Where the position is saved
Debezium saves how far the connector got, so that after a restart it goes on from there. With the default offsetStorage (org.apache.kafka.connect.storage.FileOffsetBackingStore), the position is saved to the file of offsetStorageFileName. The file is created when it does not exist, but its folder must exist and be writable: the consumer fails when it starts otherwise, as without it nothing is saved and a restart sends everything again, the snapshot included. A relative name is in the folder the integration runs in, such as data/offset-file-1.dat.
With the file schema history (schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory), the file of schemaHistoryInternalFileFilename is checked as well; Debezium creates its folders when they do not exist.
To save the position in a Kafka topic instead, such as for an integration that has no lasting disk, set offsetStorage to org.apache.kafka.connect.storage.KafkaOffsetBackingStore, with offsetStorageTopic, offsetStoragePartitions, offsetStorageReplicationFactor and the Kafka brokers as additionalProperties.bootstrap.servers.
Examples
Consuming events
Here is a basic route that you can use to listen to Debezium events from the db2 connector:
-
Java
-
XML
-
YAML
from("debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata ${headers.CamelDebeziumSourceMetadata}")
.log(" the event occurred upon this operation '${headers.CamelDebeziumOperation}'")
.log(" on this database '${headers.CamelDebeziumSourceMetadata[db]}' and this table '${headers.CamelDebeziumSourceMetadata[table]}'")
.log(" with the key ${headers.CamelDebeziumKey}")
.log(" the previous value is ${headers.CamelDebeziumBefore}"); <route>
<from uri="debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata ${headers.CamelDebeziumSourceMetadata}"/>
<log message=" the event occurred upon this operation '${headers.CamelDebeziumOperation}'"/>
<log message=" on this database '${headers.CamelDebeziumSourceMetadata[db]}' and this table '${headers.CamelDebeziumSourceMetadata[table]}'"/>
<log message=" with the key ${headers.CamelDebeziumKey}"/>
<log message=" the previous value is ${headers.CamelDebeziumBefore}"/>
</route> - route:
from:
uri: debezium-db2:dbz-test-1
parameters:
offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
- log:
message: " with this identifier ${headers.CamelDebeziumIdentifier}"
- log:
message: " with these source metadata ${headers.CamelDebeziumSourceMetadata}"
- log:
message: " the event occurred upon this operation '${headers.CamelDebeziumOperation}'"
- log:
message: " on this database '${headers.CamelDebeziumSourceMetadata[db]}' and this table '${headers.CamelDebeziumSourceMetadata[table]}'"
- log:
message: " with the key ${headers.CamelDebeziumKey}"
- log:
message: " the previous value is ${headers.CamelDebeziumBefore}" By default, the component will emit the events in the body and CamelDebeziumBefore header as Struct data type, the reasoning behind this, is to perceive the schema information in case is needed. However, the component as well contains a Type Converter that converts from default output type of Struct to Map in order to leverage Camel’s rich Data Format types which many of them work out of box with Map data type. To use it, you can either add Map.class type when you access the message (e.g., exchange.getIn().getBody(Map.class)), or you can convert the body always to Map from the route builder by adding .convertBodyTo(Map.class) to your Camel Route DSL after from statement.
We mentioned above the schema, which can be used in case you need to perform advance data transformation and the schema is needed for that. If you choose not to convert your body to Map, you can obtain the schema information as Schema type from Struct like this:
from("debezium-db2:[name]?[options]])
.process(exchange -> {
final Struct bodyValue = exchange.getIn().getBody(Struct.class);
final Schema schemaValue = bodyValue.schema();
log.info("Body value is : {}", bodyValue);
log.info("With Schema : {}", schemaValue);
log.info("And fields of : {}", schemaValue.fields());
log.info("Field name has `{}` type", schemaValue.field("name").schema());
}); | This component is a thin wrapper around Debezium Engine as mentioned. Therefore, before using this component in production, you need to understand how Debezium works and how configurations can reflect the expected behavior. This is especially true in regard to handling failures. |