Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ description: "Describes Change Data Capture (CDC) services in Studio Pro, which

{{% alert color="warning" %}} This feature is in beta. For more information, see [Release Status](/releasenotes/release-status/). {{% /alert %}}

Change Data Capture (CDC) lets you stream domain model data out of a Mendix app in near real time. When objects in a tracked entity are created, updated, or deleted, the Mendix Runtime captures those changes and publishes them as events to a Kafka topic, a named stream of records. Downstream systems, such as data warehouses or analytics pipelines, can then consume the stream without polling the Mendix database.
Change Data Capture (CDC) lets you stream domain model data out of a Mendix app in near real time. When objects in a tracked entity are created, updated, or deleted, the Mendix Runtime captures those changes and publishes them as events to a [Kafka topic](/refguide/kafka-concepts/#topic). Downstream systems, such as data warehouses or analytics pipelines, can then consume the stream without polling the Mendix database.

CDC is intended for developers who need to move Mendix domain model data to external data stores, such as a data warehouse, data lake, or blob storage.

## How It Works {#how-it-works}

A CDC service document in Studio Pro defines which entities the Mendix Runtime should track. On deployment, each tracked entity gets its own Kafka topic. When an object creation, update, or deletion is committed, the Runtime publishes a CDC event to that entity's topic.

At startup, CDC checks whether a tracked entity needs a snapshot, for example, after a breaking change creates a new topic. A snapshot populates the topic with the entity's current data as read events. For more information, see the [Revisions](/refguide/published-cdc-services/#revisions) section of *Published CDC Services*.
At startup, CDC checks whether a tracked entity has a [new topic](/refguide/published-cdc-services/#topic). If it does, the entity needs a snapshot. A snapshot populates the topic with the entity's current data as read events. For more information, see the [Snapshot Settings](#snapshot-settings) below and the [Revisions](/refguide/published-cdc-services/#revisions) section of *Published CDC Services*.

To publish a CDC event, the Runtime creates a [Kafka record](/refguide/kafka-concepts/#record-event-and-message) and submits it to the producer, the Kafka client responsible for sending records to Kafka. The record specifies the [topic for the tracked entity](/refguide/published-cdc-services/#topic) and carries the object ID as the key and the event as the JSON value.

The Runtime processes CDC events in groups but submits each Kafka record individually. The producer chooses a partition for each record, which is an ordered log within a topic. It can then combine records for the same partition into a Kafka record batch.
The Runtime processes CDC events in [groups](/refguide/kafka-concepts/#cdc-event-groups), and the producer sends the resulting records to the topic's partitions in [Kafka record batches](/refguide/kafka-concepts/#kafka-record-batch). If the Runtime closes the producer after an error, it creates a replacement when needed.

The [batch-size gauges](/refguide/metrics/#cdc-producer-metrics) measure Kafka record batches, not the groups of events processed by the Runtime. If the Runtime closes the producer after an error, it creates a replacement when needed.
Comment thread
fazzdev marked this conversation as resolved.
Resolved

The [Mendix Event Broker](/appstore/services/event-broker/) or your own Kafka cluster receives the records. For connection settings, see [Kafka Connection Settings](#kafka-connection-settings). For more about clusters, topics, and partitions, see [Kafka Concepts](/refguide/kafka-concepts/).
The Kafka cluster (either the [Mendix Event Broker](/appstore/services/event-broker/) or a Bring Your Own Kafka (BYOK) cluster), receives these records. For connection settings, see the [Kafka Connection Settings](#kafka-connection-settings) section below. For more information about clusters, topics, and partitions, see [Kafka Concepts](/refguide/kafka-concepts/).

After deployment, configure an [Event Broker Bridge](/appstore/services/event-broker-bridges/) in the Event Broker Manager to route the stream to a destination such as Azure Blob Storage or AWS S3.

Expand All @@ -36,7 +34,7 @@ Change Data Capture is not available for Free Apps. A licensed Mendix Cloud envi
{{% /alert %}}

* A licensed Mendix Cloud environment
* A [Mendix Event Broker](/appstore/services/event-broker/) license, or a BYOK Kafka cluster configured as described in [Mendix Event Broker](/appstore/services/event-broker/)
* A [Mendix Event Broker](/appstore/services/event-broker/) license, or a BYOK cluster configured as described in [Mendix Event Broker](/appstore/services/event-broker/)
* An [Event Broker Bridge](/appstore/services/event-broker-bridges/) configured in the Event Broker Manager if you want to route CDC events to external storage

## Setting Up Change Data Capture
Expand Down Expand Up @@ -64,16 +62,16 @@ The following runtime settings control connections to the Kafka broker:
| `Kafka.BootstrapServers` | One or more Kafka broker addresses. Supply a comma-separated list of `host:port` pairs, such as `broker1:9092,broker2:9092`. | Not set |
| `Kafka.Username` | The username for SCRAM-SHA-512 authentication over TLS. This setting is ignored when `Kafka.Security.Protocol` is set. | Not set |
| `Kafka.Password` | The password for SCRAM-SHA-512 authentication over TLS. This setting is ignored when `Kafka.Security.Protocol` is set. | Not set |
| `Kafka.Security.Protocol` | The [Kafka security protocol](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_security.protocol) configured on your broker listener (introduced in Mendix 11.16.0.). The possible values are: <br><ul><li> `PLAINTEXT` (no authentication or encryption)</li><li> `SSL` (TLS) </li><li> `SASL_PLAINTEXT` (SASL authentication without encryption) </li><li> `SASL_SSL` (SASL authentication over TLS) </li> | Not set |
| `Kafka.Sasl.Mechanism` | The [SASL authentication mechanism](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_sasl.mechanism) enabled on your broker listener (introduced in Mendix 11.16.0.). [Kafka's built-in mechanisms](https://kafka.apache.org/44/security/authentication-using-sasl/#sasl-mechanisms) requires `Kafka.Security.Protocol`. The built-in mechanisms are: <br><ul><li> `GSSAPI` (Kerberos) </li><li> `PLAIN` </li><li> `SCRAM-SHA-256` </li><li> `SCRAM-SHA-512` </li><li> `OAUTHBEARER` </li> | Not set |
| `Kafka.Sasl.Jaas.Config` | The [Kafka JAAS configuration](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_sasl.jaas.config)(introduced in Mendix 11.16.0.). It contains the client login module and options for your SASL mechanism. Requires `Kafka.Security.Protocol`. | Not set |
| `Kafka.Security.Protocol` | The [Kafka security protocol](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_security.protocol) configured on your broker listener (introduced in Studio Pro 11.16.0.). The possible values are: <br><ul><li> `PLAINTEXT` (no authentication or encryption)</li><li> `SSL` (TLS) </li><li> `SASL_PLAINTEXT` (SASL authentication without encryption) </li><li> `SASL_SSL` (SASL authentication over TLS) </li> | Not set |
| `Kafka.Sasl.Mechanism` | The [SASL authentication mechanism](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_sasl.mechanism) enabled on your broker listener (introduced in Studio Pro 11.16.0.). [Kafka's built-in mechanisms](https://kafka.apache.org/44/security/authentication-using-sasl/#sasl-mechanisms) requires `Kafka.Security.Protocol`. The built-in mechanisms are: <br><ul><li> `GSSAPI` (Kerberos) </li><li> `PLAIN` </li><li> `SCRAM-SHA-256` </li><li> `SCRAM-SHA-512` </li><li> `OAUTHBEARER` </li> | Not set |
| `Kafka.Sasl.Jaas.Config` | The [Kafka JAAS configuration](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_sasl.jaas.config)(introduced in Studio Pro 11.16.0.). It contains the client login module and options for your SASL mechanism. Requires `Kafka.Security.Protocol`. | Not set |
| `EventBroker.Space` | The Event Broker space in which the app is placed. This defines which other applications can exchange events with this app. | `local` |

In Mendix Cloud environments with Mendix Event Broker enabled, the platform manages broker connection credentials. For Bring Your Own Kafka (BYOK) deployments, configure the settings above through [custom runtime settings](/refguide/custom-settings/) in your environment.
In Mendix Cloud environments with Mendix Event Broker enabled, the platform manages broker connection credentials. For BYOK deployments, configure the settings above through [custom runtime settings](/refguide/custom-settings/) in your environment.

### Running Locally {#local-configuration}

As of Mendix 11.16.0, Studio Pro provides a **Kafka** tab for simplified local configuration.
As of Studio Pro 11.16.0, Studio Pro provides a **Kafka** tab for simplified local configuration.

The **Kafka** tab can be found in the App Explorer under **Settings** > [Configurations](/refguide/configurations-tab/) > **Kafka**.

Expand Down Expand Up @@ -111,21 +109,57 @@ For an unauthenticated plaintext connection, leave the credentials empty and rem

### Active-Producer Election {#active-producer-election}

In a horizontally-scaled deployment, multiple app instances could publish the same CDC events to the same Kafka topics, resulting in duplicates. CDC active-producer election prevents this by selecting a single Mendix app instance to publish events at a time. It does not select the Kafka broker that leads a partition.
{{% alert type="info" %}}
This section only applies to apps that run in a multi-instance setup, which means more than one instance of the same app. If your app runs a single instance, do not change these settings.
{{% /alert %}}

In a horizontally scaled deployment, multiple app instances could publish the same CDC events to the same Kafka topics, resulting in duplicates. CDC active-producer election prevents this by selecting a single Mendix app instance to publish events at a time. It does not select the Kafka broker that leads a partition.

Active-producer election requires all three runtime settings:
Active-producer election requires all three of the following runtime settings:

| Name | Description | Default Value |
| --- | --- | --- |
| `EventBroker.CdcActiveProducerElectionTopic` | The Kafka topic all instances subscribe to for the election. | Not set |
| `EventBroker.CdcActiveProducerElectionGroupId` | The Kafka consumer group ID all instances join for the election. | Not set |
| `EventBroker.CdcProducerTransactionId` | The Kafka transactional ID the active producer uses to publish events. | Not set |

* `EventBroker.CdcActiveProducerElectionTopic` – the Kafka topic used for election
* `EventBroker.CdcActiveProducerElectionGroupId` – the Kafka consumer group that the app instances join
* `EventBroker.CdcProducerTransactionId` – the transaction ID for the active producer
With the Mendix Event Broker, the platform sets these runtime settings for you. With BYOK, set all three as [custom runtime settings](/refguide/custom-settings/) on every instance. For example values, see the [Example for BYOK](#active-producer-election-example) section below.

With these settings, each instance joins the same Kafka consumer group and subscribes to the election topic. Kafka assigns partition 0 of that topic to exactly one group member, and that instance becomes the active producer. All other instances stand by without publishing.

If the active instance stops sending heartbeats (for example, because it crashed or was scaled down), Kafka triggers a rebalance and assigns the partition to another instance, which then starts producing. Before relinquishing the partition, the departing instance drains any in-flight events to prevent gaps.

The `EventBroker.CdcProducerTransactionId` setting enables Kafka transactions on the active producer, providing exactly-once delivery guarantees during normal operation and a clean handover during failover.

If any of these settings is missing, each instance starts publishing without election. If some but not all settings are configured, the Runtime logs the missing settings at debug level.
If any of these settings are missing, the election does not run and each instance publishes, so consumers receive duplicate events. If some but not all settings are configured, the runtime logs the missing settings at debug level.

#### Example for BYOK {#active-producer-election-example}

The following values suit an app in a multi-instance setup. Use the same values on every instance of the app:

| Name | Example Value |
| --- | --- |
| `EventBroker.CdcActiveProducerElectionTopic` | `mycompany.crm.cdc-election` |
| `EventBroker.CdcActiveProducerElectionGroupId` | `mycompany-crm-cdc-election` |
| `EventBroker.CdcProducerTransactionId` | `mycompany-crm-cdc-producer` |

Follow these rules when you choose the values:

* Use the same values on all instances of one app. If the values differ, each instance elects itself and publishes.
* Use different values for each app and each environment. Apps that share a group ID or transactional ID compete in the same election.

### Snapshot Settings {#snapshot-settings}

A snapshot publishes the current data of a tracked entity to its Kafka topic as read events. At startup, one instance of the app decides which entities need a snapshot. An entity needs a snapshot when it is new, or when its topic name changed since its last snapshot.

The following runtime settings control this decision:

| Name | Description | Default Value |
| --- | --- | --- |
| `Datastorage.StartSnapshotMinInterval` | The minimum time between two startup snapshots of new or changed entities. If the last snapshot is more recent, the runtime skips the snapshot and tries again at the next startup. This setting does not apply to entities in `EventBroker.CdcForceSnapshotEntities`. Enter a number of milliseconds, such as `300000`, or a value with a unit, such as `5 minutes`. | 5 minutes |
| `EventBroker.CdcForceSnapshotEntities` | A comma-separated list of tracked entities, such as `MyModule.Customer,MyModule.Order`. At every startup, the runtime creates a snapshot of each listed entity, even when its topic name did not change. The Runtime ignores entries that are not tracked entities and logs a warning for them. This setting was introduced in Studio Pro 11.12.1. | Not set |

Because the forced snapshot runs at every startup, remove an entity from `EventBroker.CdcForceSnapshotEntities` when you no longer need repeated snapshots. Consumers receive the snapshot events as read (`r`) events. For more information, see [Message Format](#message-format).

### Message Format {#message-format}

Expand Down Expand Up @@ -157,7 +191,7 @@ The `source` block contains the following fields:

Because the format is Debezium-compatible, BYOK consumers that already support Debezium (such as Kafka Connect sink connectors for databases or data warehouses) can consume CDC events without any message transformation.

To parse CDC events, use the schema for the tracked entity in its AsyncAPI document. The document uses an [AsyncAPI channel](/refguide/kafka-concepts/#asyncapi-channel) to describe where applications send or receive messages. You can download the AsyncAPI document from the CDC service details page in the [Event Broker Manager](https://broker.mendix.com/).
To parse CDC events, use the schema for the tracked entity in its AsyncAPI document, which describes each topic as an [AsyncAPI channel](/refguide/kafka-concepts/#asyncapi-channel). You can download the AsyncAPI document from the CDC service details page in the [Event Broker Manager](https://broker.mendix.com/).

For details on setting up a BYOK cluster with the Mendix Event Broker, see [Mendix Event Broker](/appstore/services/event-broker/).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: "Describes Kafka terms used in Mendix Change Data Capture, includin

## Introduction

Use this document to look up Kafka terms you encounter when setting up or monitoring Mendix [hange Data Capture (CDC) For details about what the Mendix Runtime sends to Kafka, see the [How It Works](/refguide/change-data-capture/#how-it-works) section of *Change Data Capture*.
Use this document to look up Kafka terms you encounter when setting up or monitoring Mendix Change Data Capture (CDC). For details about what the Mendix Runtime sends to Kafka, see the [How It Works](/refguide/change-data-capture/#how-it-works) section of *Change Data Capture*.

## Where Kafka Stores Records

Expand Down Expand Up @@ -35,22 +35,18 @@ A Kafka record is the item written to a topic. Kafka documentation may also call

### Kafka Record Batch {#kafka-record-batch}

The producer can send records for the same partition together in a record batch. One produce request can carry batches for multiple partitions. The [CDC batch-size gauges](/refguide/metrics/#cdc-producer-metrics) measure Kafka record batches, not the groups of events the Mendix Runtime processes.
The producer can send records for the same partition together in a record batch. As of Studio Pro 11.16.0 and 11.12.6, the Mendix producer waits up to 10 milliseconds to fill a batch of up to 64 KiB. You cannot change these values. One produce request can carry batches for multiple partitions. The [CDC producer metrics](/refguide/metrics/#cdc-producer-metrics) report on these batches.

## Terms in the CDC Guide

### Groups of CDC Events {#cdc-event-groups}

The Mendix Runtime processes CDC events in groups before submitting the resulting records to the Kafka producer individually. These groups are separate from [Kafka record batches](#kafka-record-batch), which the producer creates.
The Mendix Runtime processes CDC events in groups before submitting the resulting records to the Kafka producer individually. These groups are separate from [Kafka record batches](#kafka-record-batch), which the producer creates. The [CDC batch-size gauges](/refguide/metrics/#cdc-producer-metrics) measure record batches, not these groups.

### AsyncAPI Channel {#asyncapi-channel}

An AsyncAPI channel describes where applications send or receive messages. In an AsyncAPI document for Kafka, a channel can represent a Kafka topic. See [Message Format](/refguide/change-data-capture/#message-format) for where to find the CDC schema.

### CDC Active-Producer Election {#cdc-active-producer-election}

CDC active-producer election selects one Mendix app instance to publish CDC events. It does not select the Kafka broker that leads a partition. For configuration and failover behavior, see [Active-Producer Election](/refguide/change-data-capture/#active-producer-election).

## Read More

* [Apache Kafka Main Concepts and Terminology](https://kafka.apache.org/44/getting-started/introduction/#main-concepts-and-terminology)
Loading