Camel Components

Debezium MongoDB Connector

Since Camel 3.0

Only consumer is supported

The Debezium MongoDB component is wrapper around Debezium using Debezium Engine, which enables Change Data Capture from MongoDB database using Debezium without the need for Kafka or Kafka Connect.

The Debezium MongoDB connector uses MongoDB’s oplog to capture the changes. The connector works only with the MongoDB replica sets or with sharded clusters, where each shard is a separate replica set. Therefore, you will need to have your MongoDB instance running either in replica set mode or sharded clusters mode.

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 (DOWN by default). It reports UP once the connector tasks have started and the engine enters its polling phase, even if no change events have arrived. This does not indicate that an initial snapshot has completed.

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 internal.task.management.timeout.ms (40 seconds by default, set with additionalProperties.internal.task.management.timeout.ms) to start, and the start waits that long for each task and once more for the connector; if the engine has not reported back by then, the route starts anyway, with a WARN in the log.

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 bridgeErrorHandler=true, to the error handler of the route) and turns the route health check DOWN, so it can be picked up by a readiness probe.

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-mongodb</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

debezium-mongodb:name[?options]

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, *.yaml files, 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 MongoDB Connector component supports the following options which are listed below.

Name Description Default Type

additionalProperties (common)

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

bridgeErrorHandler (consumer)

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

configuration (consumer)

Allow pre-configured Configurations to be set.

MongoDbConnectorEmbeddedDebeziumConfiguration

internalKeyConverter (consumer)

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

internalValueConverter (consumer)

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

offsetCommitPolicy (consumer)

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

offsetCommitTimeoutMs (consumer)

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

offsetFlushIntervalMs (consumer)

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

offsetStorage (consumer)

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

offsetStorageFileName (consumer)

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

offsetStoragePartitions (consumer)

The number of partitions of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore.

int

offsetStorageReplicationFactor (consumer)

The replication factor of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore.

int

offsetStorageTopic (consumer)

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

autowiredEnabled (advanced)

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

binaryHandlingMode (mongodb)

Specify how binary (blob, binary, etc.) columns should be represented in change events, including: 'bytes' represents binary data as byte array (default); 'base64' represents binary data as base64-encoded string; 'base64-url-safe' represents binary data as base64-url-safe-encoded string; 'hex' represents binary data as hex-encoded (base16) string.

bytes

String

captureMode (mongodb)

The method used to capture changes from MongoDB server. Options include: 'change_streams' to capture changes via MongoDB Change Streams, update events do not contain full documents; 'change_streams_update_full' (the default) to capture changes via MongoDB Change Streams, update events contain full documents.

change_streams_update_full

String

captureScope (mongodb)

The scope of captured changes. Options include: 'deployment' (the default) to capture changes from the entire MongoDB deployment; 'database' to capture changes from a specific MongoDB database’collection' to capture changes from a specific MongoDB collection.

deployment

String

captureTarget (mongodb)

The target to capture changes from. For 'database' scope, this is the database name. For 'collection' scope, this is the collection name as {databaseName}.{collectionName}.

String

collectionExcludeList (mongodb)

A comma-separated list of regular expressions or literals that match the collection names for which changes are to be excluded.

String

collectionIncludeList (mongodb)

A comma-separated list of regular expressions or literals that match the collection names for which changes are to be captured.

String

connectionValidationTimeoutMs (mongodb)

The maximum time in milliseconds to wait for connection validation to complete. Defaults to 60 seconds.

1m

long

converters (mongodb)

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

cursorMaxAwaitTimeMs (mongodb)

The maximum processing time in milliseconds to wait for the oplog cursor to process a single poll request.

int

customMetricTags (mongodb)

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

customSanitizePattern (mongodb)

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

databaseExcludeList (mongodb)

A comma-separated list of regular expressions or literals that match the database names for which changes are to be excluded.

String

databaseIncludeList (mongodb)

A comma-separated list of regular expressions or literals that match the database names for which changes are to be captured.

String

errorsMaxRetries (mongodb)

The maximum number of retries on connection errors before failing (-1 = no limit, 0 = disabled, > 0 = num of retries).

-1

int

eventConvertingFailureHandlingMode (mongodb)

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

eventProcessingFailureHandlingMode (mongodb)

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

executorShutdownTimeoutMs (mongodb)

The maximum time in milliseconds to wait for task executor to shut down.

4s

long

extendedHeadersEnabled (mongodb)

Enable/Disable Debezium context headers that provides essential metadata for tracking and identifying the source of CDC events in downstream processing systems.

true

boolean

fieldExcludeList (mongodb)

A comma-separated list of the fully-qualified names of fields that should be excluded from change event message values.

String

fieldNameAdjustmentMode (mongodb)

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

fieldRenames (mongodb)

A comma-separated list of the fully-qualified replacements of fields that should be used to rename fields in change event message values. Fully-qualified replacements for fields are of the form databaseName.collectionName.fieldName.nestedFieldName:newNestedFieldName, where databaseName and collectionName may contain the wildcard (*) which matches any characters, the colon character (:) is used to determine rename mapping of field.

String

guardrailCollectionsLimitAction (mongodb)

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

guardrailCollectionsMax (mongodb)

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

heartbeatIntervalMs (mongodb)

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

heartbeatTopicsPrefix (mongodb)

The prefix that is used to name heartbeat topics.Defaults to __debezium-heartbeat.

__debezium-heartbeat

String

incrementalSnapshotAllowSchemaChanges (mongodb)

Detect schema change during an incremental snapshot and re-select a current chunk to avoid locking DDLs. Note that changes to a primary key are not supported and can cause incorrect results if performed during an incremental snapshot. Another limitation is that if a schema change affects only columns' default values, then the change won’t be detected until the DDL is processed from the binlog stream. This doesn’t affect the snapshot events' values, but the schema of snapshot events may have outdated defaults.

false

boolean

incrementalSnapshotChunkSize (mongodb)

The maximum size of chunk (number of documents/rows) for incremental snapshotting.

1024

int

incrementalSnapshotWatermarkingStrategy (mongodb)

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

jsonSerializationMode (mongodb)

Controls the Extended JSON serialization mode used for MongoDB event payload fields. Options include: 'legacy' (the default) uses MongoDB Extended JSON v1 strict mode for full document fields and MongoDB Extended JSON v2 relaxed mode for update fields. 'strict' uses MongoDB Extended JSON v1 strict mode. 'extended' uses MongoDB Extended JSON v2 canonical mode. 'relaxed' uses MongoDB Extended JSON v2 relaxed mode.

legacy

String

legacySnapshotMaxThreads (mongodb)

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

maxBatchSize (mongodb)

Maximum size of each batch of source records. Defaults to 2048.

2048

int

maxQueueSize (mongodb)

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

maxQueueSizeInBytes (mongodb)

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

mongodbAuthsource (mongodb)

Database containing user credentials.

admin

String

mongodbConnectionString (mongodb)

Database connection string.

String

mongodbConnectTimeoutMs (mongodb)

The connection timeout, given in milliseconds. Defaults to 10 seconds (10,000 ms).

10s

int

mongodbHeartbeatFrequencyMs (mongodb)

The frequency that the cluster monitor attempts to reach each server. Defaults to 10 seconds (10,000 ms).

10s

int

mongodbPassword (mongodb)

Required Password to be used when connecting to MongoDB, if necessary.

String

mongodbPollIntervalMs (mongodb)

Interval for looking for new, removed, or changed replica sets, given in milliseconds. Defaults to 30 seconds (30,000 ms).

30s

long

mongodbServerSelectionTimeoutMs (mongodb)

The server selection timeout, given in milliseconds. Defaults to 10 seconds (10,000 ms).

30s

int

mongodbSocketTimeoutMs (mongodb)

The socket timeout, given in milliseconds. Defaults to 0 ms.

0ms

int

mongodbSslEnabled (mongodb)

Should connector use SSL to connect to MongoDB instances.

false

boolean

mongodbSslInvalidHostnameAllowed (mongodb)

Whether invalid host names are allowed when using SSL. If true the connection will not prevent man-in-the-middle attacks.

false

boolean

mongodbUser (mongodb)

Database user for connecting to MongoDB, if necessary.

String

notificationEnabledChannels (mongodb)

List of notification channels names that are enabled.

String

notificationHttpAllowPrivateNetworks (mongodb)

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

notificationHttpRetries (mongodb)

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

notificationHttpTimeoutMs (mongodb)

Connect and read timeout, in milliseconds, for HTTP notification delivery.

5s

int

notificationHttpUrl (mongodb)

The URL to which notifications are POSTed as JSON. Required when 'http' is in the list of enabled channels.

String

notificationSinkTopicName (mongodb)

The name of the topic for the notifications. This is required in case 'sink' is in the list of enabled channels.

String

openlineageIntegrationConfigFilePath (mongodb)

Path to OpenLineage file configuration. See https://openlineage.io/docs/client/java/configuration.

./openlineage.yml

String

openlineageIntegrationDatasetKafkaBootstrapServers (mongodb)

The Kafka bootstrap server address used as input/output namespace/.

String

openlineageIntegrationEnabled (mongodb)

Enable Debezium to emit data lineage metadata through OpenLineage API.

false

boolean

openlineageIntegrationJobDescription (mongodb)

The job’s description emitted by Debezium.

Debezium change data capture job

String

openlineageIntegrationJobNamespace (mongodb)

The job’s namespace emitted by Debezium.

String

openlineageIntegrationJobOwners (mongodb)

The job’s owners emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2.

String

openlineageIntegrationJobTags (mongodb)

The job’s tags emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2.

String

pollIntervalMs (mongodb)

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

postProcessors (mongodb)

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

provideTransactionMetadata (mongodb)

Enables transaction metadata extraction together with event counting.

false

boolean

queryFetchSize (mongodb)

The maximum number of records that should be loaded into memory while streaming. A value of '0' uses the default JDBC fetch size.

0

int

retriableRestartConnectorWaitMs (mongodb)

Time to wait before restarting connector after retriable exception occurs. Defaults to 10000ms.

10s

long

schemaHistoryInternalFileFilename (mongodb)

The path to the file that will be used to record the database schema history.

String

schemaNameAdjustmentMode (mongodb)

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

signalDataCollection (mongodb)

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

signalEmitFailureBackoffMs (mongodb)

Duration to sleep for after encountering an error emitting a window event, given in milliseconds. Defaults to 10 seconds.

10s

long

signalEmitFailureMaxRetries (mongodb)

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

signalEnabledChannels (mongodb)

List of channels names that are enabled. Source channel is enabled by default.

source

String

signalPollIntervalMs (mongodb)

Interval for looking for new signals in registered channels, given in milliseconds. Defaults to 5 seconds.

5s

long

skipMessagesWithoutChange (mongodb)

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

skippedOperations (mongodb)

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

snapshotCollectionFilterOverrides (mongodb)

This property contains a comma-separated list of {dbName}.{collectionName}, for which the initial snapshot may be a subset of data present in the data source. The subset would be defined by mongodb filter query specified as value for property snapshot.collection.filter.override.{dbname}.{collectionName}.

String

snapshotDelayMs (mongodb)

A delay period before a snapshot will begin, given in milliseconds. Defaults to 0 ms.

0ms

long

snapshotFetchSize (mongodb)

The maximum number of records that should be loaded into memory while performing a snapshot.

int

snapshotIncludeCollectionList (mongodb)

This setting must be set to specify a list of tables/collections whose snapshot must be taken on creating or restarting the connector.

String

snapshotMaxThreads (mongodb)

The maximum number of threads used to perform the snapshot. Defaults to 1.

1

int

snapshotMaxThreadsMultiplier (mongodb)

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

snapshotMode (mongodb)

The criteria for running a snapshot upon startup of the connector. Select one of the following snapshot options: 'initial' (default): If the connector does not detect any offsets for the logical server name, it runs a snapshot that captures the current full state of the configured tables. After the snapshot completes, the connector begins to stream changes from the oplog. 'never': The connector does not run a snapshot. Upon first startup, the connector immediately begins reading from the beginning of the oplog.

initial

String

snapshotModeConfigurationBasedSnapshotData (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not.

false

boolean

snapshotModeConfigurationBasedSnapshotOnDataError (mongodb)

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

snapshotModeConfigurationBasedSnapshotOnSchemaError (mongodb)

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

snapshotModeConfigurationBasedSnapshotSchema (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not.

false

boolean

snapshotModeConfigurationBasedStartStream (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the stream should start or not after snapshot.

false

boolean

snapshotModeCustomName (mongodb)

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

sourceinfoStructMaker (mongodb)

The name of the SourceInfoStructMaker class that returns SourceInfo schema and struct.

io.debezium.connector.mongodb.MongoDbSourceInfoStructMaker

String

statisticsMetricsEnabled (mongodb)

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

streamingDelayMs (mongodb)

A delay period after the snapshot is completed and the streaming begins, given in milliseconds. Defaults to 0 ms.

0ms

long

tombstonesOnDelete (mongodb)

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

topicNamingStrategy (mongodb)

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

topicPrefix (mongodb)

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

transactionMetadataFactory (mongodb)

Class to make transaction context & transaction struct/schemas.

io.debezium.pipeline.txmetadata.DefaultTransactionMetadataFactory

String

Endpoint Options

The Debezium MongoDB Connector endpoint is configured using URI syntax:

debezium-mongodb:name

With the following path and query parameters:

Path Parameters

Name Description Default Type

name (consumer)

Required The name of the connector, which is also the name of the Debezium engine. The offsets are stored by this name: a connector with a new name starts from the beginning again, as set by its snapshot mode.

String

Query Parameters

Name Description Default Type

additionalProperties (common)

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

internalKeyConverter (consumer)

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

internalValueConverter (consumer)

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

offsetCommitPolicy (consumer)

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

offsetCommitTimeoutMs (consumer)

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

offsetFlushIntervalMs (consumer)

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

offsetStorage (consumer)

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

offsetStorageFileName (consumer)

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

offsetStoragePartitions (consumer)

The number of partitions of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore.

int

offsetStorageReplicationFactor (consumer)

The replication factor of the offset topic, when the KafkaOffsetBackingStore creates it. Required when offsetStorage is the KafkaOffsetBackingStore.

int

offsetStorageTopic (consumer)

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

bridgeErrorHandler (consumer (advanced))

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

exceptionHandler (consumer (advanced))

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

exchangePattern (consumer (advanced))

Sets the exchange pattern when the consumer creates an exchange.

Enum values:

  • InOnly

  • InOut

ExchangePattern

binaryHandlingMode (mongodb)

Specify how binary (blob, binary, etc.) columns should be represented in change events, including: 'bytes' represents binary data as byte array (default); 'base64' represents binary data as base64-encoded string; 'base64-url-safe' represents binary data as base64-url-safe-encoded string; 'hex' represents binary data as hex-encoded (base16) string.

bytes

String

captureMode (mongodb)

The method used to capture changes from MongoDB server. Options include: 'change_streams' to capture changes via MongoDB Change Streams, update events do not contain full documents; 'change_streams_update_full' (the default) to capture changes via MongoDB Change Streams, update events contain full documents.

change_streams_update_full

String

captureScope (mongodb)

The scope of captured changes. Options include: 'deployment' (the default) to capture changes from the entire MongoDB deployment; 'database' to capture changes from a specific MongoDB database’collection' to capture changes from a specific MongoDB collection.

deployment

String

captureTarget (mongodb)

The target to capture changes from. For 'database' scope, this is the database name. For 'collection' scope, this is the collection name as {databaseName}.{collectionName}.

String

collectionExcludeList (mongodb)

A comma-separated list of regular expressions or literals that match the collection names for which changes are to be excluded.

String

collectionIncludeList (mongodb)

A comma-separated list of regular expressions or literals that match the collection names for which changes are to be captured.

String

connectionValidationTimeoutMs (mongodb)

The maximum time in milliseconds to wait for connection validation to complete. Defaults to 60 seconds.

1m

long

converters (mongodb)

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

cursorMaxAwaitTimeMs (mongodb)

The maximum processing time in milliseconds to wait for the oplog cursor to process a single poll request.

int

customMetricTags (mongodb)

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

customSanitizePattern (mongodb)

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

databaseExcludeList (mongodb)

A comma-separated list of regular expressions or literals that match the database names for which changes are to be excluded.

String

databaseIncludeList (mongodb)

A comma-separated list of regular expressions or literals that match the database names for which changes are to be captured.

String

errorsMaxRetries (mongodb)

The maximum number of retries on connection errors before failing (-1 = no limit, 0 = disabled, > 0 = num of retries).

-1

int

eventConvertingFailureHandlingMode (mongodb)

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

eventProcessingFailureHandlingMode (mongodb)

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

executorShutdownTimeoutMs (mongodb)

The maximum time in milliseconds to wait for task executor to shut down.

4s

long

extendedHeadersEnabled (mongodb)

Enable/Disable Debezium context headers that provides essential metadata for tracking and identifying the source of CDC events in downstream processing systems.

true

boolean

fieldExcludeList (mongodb)

A comma-separated list of the fully-qualified names of fields that should be excluded from change event message values.

String

fieldNameAdjustmentMode (mongodb)

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

fieldRenames (mongodb)

A comma-separated list of the fully-qualified replacements of fields that should be used to rename fields in change event message values. Fully-qualified replacements for fields are of the form databaseName.collectionName.fieldName.nestedFieldName:newNestedFieldName, where databaseName and collectionName may contain the wildcard (*) which matches any characters, the colon character (:) is used to determine rename mapping of field.

String

guardrailCollectionsLimitAction (mongodb)

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

guardrailCollectionsMax (mongodb)

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

heartbeatIntervalMs (mongodb)

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

heartbeatTopicsPrefix (mongodb)

The prefix that is used to name heartbeat topics.Defaults to __debezium-heartbeat.

__debezium-heartbeat

String

incrementalSnapshotAllowSchemaChanges (mongodb)

Detect schema change during an incremental snapshot and re-select a current chunk to avoid locking DDLs. Note that changes to a primary key are not supported and can cause incorrect results if performed during an incremental snapshot. Another limitation is that if a schema change affects only columns' default values, then the change won’t be detected until the DDL is processed from the binlog stream. This doesn’t affect the snapshot events' values, but the schema of snapshot events may have outdated defaults.

false

boolean

incrementalSnapshotChunkSize (mongodb)

The maximum size of chunk (number of documents/rows) for incremental snapshotting.

1024

int

incrementalSnapshotWatermarkingStrategy (mongodb)

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

jsonSerializationMode (mongodb)

Controls the Extended JSON serialization mode used for MongoDB event payload fields. Options include: 'legacy' (the default) uses MongoDB Extended JSON v1 strict mode for full document fields and MongoDB Extended JSON v2 relaxed mode for update fields. 'strict' uses MongoDB Extended JSON v1 strict mode. 'extended' uses MongoDB Extended JSON v2 canonical mode. 'relaxed' uses MongoDB Extended JSON v2 relaxed mode.

legacy

String

legacySnapshotMaxThreads (mongodb)

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

maxBatchSize (mongodb)

Maximum size of each batch of source records. Defaults to 2048.

2048

int

maxQueueSize (mongodb)

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

maxQueueSizeInBytes (mongodb)

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

mongodbAuthsource (mongodb)

Database containing user credentials.

admin

String

mongodbConnectionString (mongodb)

Database connection string.

String

mongodbConnectTimeoutMs (mongodb)

The connection timeout, given in milliseconds. Defaults to 10 seconds (10,000 ms).

10s

int

mongodbHeartbeatFrequencyMs (mongodb)

The frequency that the cluster monitor attempts to reach each server. Defaults to 10 seconds (10,000 ms).

10s

int

mongodbPassword (mongodb)

Required Password to be used when connecting to MongoDB, if necessary.

String

mongodbPollIntervalMs (mongodb)

Interval for looking for new, removed, or changed replica sets, given in milliseconds. Defaults to 30 seconds (30,000 ms).

30s

long

mongodbServerSelectionTimeoutMs (mongodb)

The server selection timeout, given in milliseconds. Defaults to 10 seconds (10,000 ms).

30s

int

mongodbSocketTimeoutMs (mongodb)

The socket timeout, given in milliseconds. Defaults to 0 ms.

0ms

int

mongodbSslEnabled (mongodb)

Should connector use SSL to connect to MongoDB instances.

false

boolean

mongodbSslInvalidHostnameAllowed (mongodb)

Whether invalid host names are allowed when using SSL. If true the connection will not prevent man-in-the-middle attacks.

false

boolean

mongodbUser (mongodb)

Database user for connecting to MongoDB, if necessary.

String

notificationEnabledChannels (mongodb)

List of notification channels names that are enabled.

String

notificationHttpAllowPrivateNetworks (mongodb)

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

notificationHttpRetries (mongodb)

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

notificationHttpTimeoutMs (mongodb)

Connect and read timeout, in milliseconds, for HTTP notification delivery.

5s

int

notificationHttpUrl (mongodb)

The URL to which notifications are POSTed as JSON. Required when 'http' is in the list of enabled channels.

String

notificationSinkTopicName (mongodb)

The name of the topic for the notifications. This is required in case 'sink' is in the list of enabled channels.

String

openlineageIntegrationConfigFilePath (mongodb)

Path to OpenLineage file configuration. See https://openlineage.io/docs/client/java/configuration.

./openlineage.yml

String

openlineageIntegrationDatasetKafkaBootstrapServers (mongodb)

The Kafka bootstrap server address used as input/output namespace/.

String

openlineageIntegrationEnabled (mongodb)

Enable Debezium to emit data lineage metadata through OpenLineage API.

false

boolean

openlineageIntegrationJobDescription (mongodb)

The job’s description emitted by Debezium.

Debezium change data capture job

String

openlineageIntegrationJobNamespace (mongodb)

The job’s namespace emitted by Debezium.

String

openlineageIntegrationJobOwners (mongodb)

The job’s owners emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2.

String

openlineageIntegrationJobTags (mongodb)

The job’s tags emitted by Debezium. A comma-separated list of key-value pairs.For example: k1=v1,k2=v2.

String

pollIntervalMs (mongodb)

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

postProcessors (mongodb)

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

provideTransactionMetadata (mongodb)

Enables transaction metadata extraction together with event counting.

false

boolean

queryFetchSize (mongodb)

The maximum number of records that should be loaded into memory while streaming. A value of '0' uses the default JDBC fetch size.

0

int

retriableRestartConnectorWaitMs (mongodb)

Time to wait before restarting connector after retriable exception occurs. Defaults to 10000ms.

10s

long

schemaHistoryInternalFileFilename (mongodb)

The path to the file that will be used to record the database schema history.

String

schemaNameAdjustmentMode (mongodb)

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

signalDataCollection (mongodb)

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

signalEmitFailureBackoffMs (mongodb)

Duration to sleep for after encountering an error emitting a window event, given in milliseconds. Defaults to 10 seconds.

10s

long

signalEmitFailureMaxRetries (mongodb)

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

signalEnabledChannels (mongodb)

List of channels names that are enabled. Source channel is enabled by default.

source

String

signalPollIntervalMs (mongodb)

Interval for looking for new signals in registered channels, given in milliseconds. Defaults to 5 seconds.

5s

long

skipMessagesWithoutChange (mongodb)

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

skippedOperations (mongodb)

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

snapshotCollectionFilterOverrides (mongodb)

This property contains a comma-separated list of {dbName}.{collectionName}, for which the initial snapshot may be a subset of data present in the data source. The subset would be defined by mongodb filter query specified as value for property snapshot.collection.filter.override.{dbname}.{collectionName}.

String

snapshotDelayMs (mongodb)

A delay period before a snapshot will begin, given in milliseconds. Defaults to 0 ms.

0ms

long

snapshotFetchSize (mongodb)

The maximum number of records that should be loaded into memory while performing a snapshot.

int

snapshotIncludeCollectionList (mongodb)

This setting must be set to specify a list of tables/collections whose snapshot must be taken on creating or restarting the connector.

String

snapshotMaxThreads (mongodb)

The maximum number of threads used to perform the snapshot. Defaults to 1.

1

int

snapshotMaxThreadsMultiplier (mongodb)

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

snapshotMode (mongodb)

The criteria for running a snapshot upon startup of the connector. Select one of the following snapshot options: 'initial' (default): If the connector does not detect any offsets for the logical server name, it runs a snapshot that captures the current full state of the configured tables. After the snapshot completes, the connector begins to stream changes from the oplog. 'never': The connector does not run a snapshot. Upon first startup, the connector immediately begins reading from the beginning of the oplog.

initial

String

snapshotModeConfigurationBasedSnapshotData (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the data should be snapshotted or not.

false

boolean

snapshotModeConfigurationBasedSnapshotOnDataError (mongodb)

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

snapshotModeConfigurationBasedSnapshotOnSchemaError (mongodb)

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

snapshotModeConfigurationBasedSnapshotSchema (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the schema should be snapshotted or not.

false

boolean

snapshotModeConfigurationBasedStartStream (mongodb)

When 'snapshot.mode' is set as configuration_based, this setting permits to specify whenever the stream should start or not after snapshot.

false

boolean

snapshotModeCustomName (mongodb)

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

sourceinfoStructMaker (mongodb)

The name of the SourceInfoStructMaker class that returns SourceInfo schema and struct.

io.debezium.connector.mongodb.MongoDbSourceInfoStructMaker

String

statisticsMetricsEnabled (mongodb)

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

streamingDelayMs (mongodb)

A delay period after the snapshot is completed and the streaming begins, given in milliseconds. Defaults to 0 ms.

0ms

long

tombstonesOnDelete (mongodb)

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

topicNamingStrategy (mongodb)

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

topicPrefix (mongodb)

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

transactionMetadataFactory (mongodb)

Class to make transaction context & transaction struct/schemas.

io.debezium.pipeline.txmetadata.DefaultTransactionMetadataFactory

String

Message Headers

The Debezium MongoDB Connector component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelDebeziumSourceMetadata (consumer)

Constant: HEADER_SOURCE_METADATA

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: HEADER_IDENTIFIER

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

CamelDebeziumKey (consumer)

Constant: HEADER_KEY

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: HEADER_OPERATION

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: HEADER_TIMESTAMP

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: HEADER_BEFORE

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: HEADER_DDL_SQL

The DDL statement of a schema change event. Not set for a row change.

String

CamelDebeziumUpdateDescription (consumer)

Constant: HEADER_UPDATE_DESCRIPTION

If presents, the description of an update: updatedFields (the changed fields as a JSON String), removedFields (the names of the removed fields) and truncatedArrays (the arrays that were truncated, with their field and new size).

Map

Message Body

The message body at each side of the Debezium MongoDB 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

text or null (java.lang.String), as json

The document after the change as a JSON String (MongoDB extended JSON): unmarshal it to work with its fields. No body for a delete or a tombstone, nor for an update when captureMode does not look up the full document or the document is gone by then; the operation and the key are in headers, and the changed fields of an update in the CamelDebeziumUpdateDescription header.

Not known when additionalProperties is set.

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.

For more information about configuration: Debezium engine properties Debezium MongoDB connector properties

Note: The CamelDebeziumBefore header holds the document before the change only when the connector captures pre-images, that is with captureMode set to change_streams_with_pre_image or change_streams_update_full_with_pre_image (MongoDB 6.0 or later, with pre-images enabled on the collection). With the other capture modes, such as the default change_streams_update_full, the header is null.

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 in String JSON format, and you can unmarshal using Camel JSON Data Format.

An update has no body when captureMode does not look up the full document (such as change_streams). The changed fields of an update are in the CamelDebeziumUpdateDescription header, as a Map with updatedFields (the changed fields as a JSON String), removedFields (the names of the removed fields) and truncatedArrays.

With the Debezium ExtractNewDocumentState single message transformation (additionalProperties.transforms=unwrap and additionalProperties.transforms.unwrap.type=io.debezium.connector.mongodb.transforms.ExtractNewDocumentState), the event is flattened to the document, and the body is that document 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.

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 MongoDB connector:

  • Java

  • XML

  • YAML

from("debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&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}")
    .choice()
        .when(header(DebeziumConstants.HEADER_OPERATION).in("c", "u", "r"))
            .unmarshal().json()
            .log("Event received from Debezium : ${body}")
         .end()
    .end();
<route>
  <from uri="debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&amp;mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&amp;mongodbUser=debezium&amp;mongodbPassword=dbz&amp;topicPrefix=dbserver1&amp;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}"/>
  <choice>
    <when>
      <simple>${headers.CamelDebeziumOperation} in 'c,u,r'</simple>
      <unmarshal><json/></unmarshal>
      <log message="Event received from Debezium : ${body}"/>
    </when>
  </choice>
</route>
- route:
    from:
      uri: debezium-mongodb:dbz-test-1
      parameters:
        offsetStorageFileName: data/offset-file-1.dat
        mongodbConnectionString: "mongodb://localhost:27017/?replicaSet=rs0"
        mongodbUser: debezium
        mongodbPassword: dbz
        topicPrefix: dbserver1
        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}"
        - choice:
            when:
              - simple: "${headers.CamelDebeziumOperation} in 'c,u,r'"
                steps:
                  - unmarshal:
                      json: {}
                  - log:
                      message: "Event received from Debezium : ${body}"

By default, the component will emit the events in the body String JSON format in case of u, c or r operations. This can be easily converted to JSON using Camel JSON Data Format e.g.: .unmarshal().json() like the above example. In case of operation d, the body will be null.

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.