|
1 |
| -================================== |
2 |
| -Sink Connector Change Data Capture |
3 |
| -================================== |
| 1 | +============================ |
| 2 | +Change Data Capture Handlers |
| 3 | +============================ |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 2 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +Overview |
| 14 | +-------- |
| 15 | + |
| 16 | +Learn how to **replicate** your **change data capture (CDC)** events with a {+mkc+} sink |
| 17 | +connector. CDC is a software architecture that converts changes in a datastore |
| 18 | +into a stream of **CDC events**. A CDC event is a message containing a |
| 19 | +reproducible representation of a change performed on a datastore. Replicating |
| 20 | +data is the process of applying the changes contained in CDC events from one data |
| 21 | +store onto a different datastore so that the changes occur in both datastores. |
| 22 | + |
| 23 | +Use a **CDC handler** to replicate CDC events stored on an {+ak+} topic into MongoDB. |
| 24 | +A CDC handler is a program that translates CDC events from a specific |
| 25 | +**CDC event producer** into MongoDB write operations. |
| 26 | + |
| 27 | +A CDC event producer is an application that generates CDC events. CDC event |
| 28 | +producers can be datastores, or applications that watch datastores and generate |
| 29 | +CDC events corresponding to changes in the datastores. |
| 30 | + |
| 31 | +.. note:: |
| 32 | + |
| 33 | + MongoDB change streams is an example of a CDC architecture. To learn more about |
| 34 | + change streams, see |
| 35 | + :doc:`the {+mkc+} guide on Change Streams </source-connector/fundamentals/change-streams>`. |
| 36 | + |
| 37 | +If you would like to view a tutorial demonstrating how to replicate data, see the |
| 38 | +:doc:`Replicate Data With a Change Data Capture Handler tutorial </tutorials/replicate-with-cdc>`. |
| 39 | + |
| 40 | +Specify a CDC Handler |
| 41 | +--------------------- |
| 42 | + |
| 43 | +You can specify a CDC handler on your sink connector with the following configuration option: |
| 44 | + |
| 45 | +.. code-block:: properties |
| 46 | + |
| 47 | + change.data.capture.handler=<cdc handler class> |
| 48 | + |
| 49 | +To learn more, see |
| 50 | +:doc:`change data capture configuration options </sink-connector/configuration-properties/cdc>` |
| 51 | +in the {+mkc+}. |
| 52 | + |
| 53 | +Available CDC Handlers |
| 54 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 55 | + |
| 56 | +The {+mkc+} provides CDC handlers for the following CDC event producers: |
| 57 | + |
| 58 | +- MongoDB |
| 59 | +- `Debezium <https://debezium.io/>`__ |
| 60 | +- `Qlik Replicate <https://www.qlik.com/us/products/qlik-replicate>`__ |
| 61 | + |
| 62 | +Click the following tabs to learn how to configure |
| 63 | +CDC handlers for the preceding event producers: |
| 64 | + |
| 65 | +.. tabs:: |
| 66 | + |
| 67 | + .. tab:: |
| 68 | + :tabid: MongoDB |
| 69 | + |
| 70 | + .. include:: /includes/fundamentals/cdc/mongodb.rst |
| 71 | + |
| 72 | + .. tab:: |
| 73 | + :tabid: Debezium |
| 74 | + |
| 75 | + .. include:: /includes/fundamentals/cdc/debezium.rst |
| 76 | + |
| 77 | + .. tab:: |
| 78 | + :tabid: Qlik Replicate |
| 79 | + |
| 80 | + .. include:: /includes/fundamentals/cdc/qlik.rst |
| 81 | + |
| 82 | +.. _cdc-create-your-own: |
| 83 | + |
| 84 | +Create Your Own CDC Handler |
| 85 | +--------------------------- |
| 86 | + |
| 87 | +If none of the prebuilt CDC handlers fit your use case, you can create your own. |
| 88 | +Your custom CDC handler is a Java class that implements the ``CdcHandler`` interface. |
| 89 | + |
| 90 | +To learn more, see the |
| 91 | +:github:`source code for the CdcHandler interface <mongodb/mongo-kafka/blob/master/src/main/java/com/mongodb/kafka/connect/sink/cdc/CdcHandler.java>`. |
| 92 | + |
| 93 | +To view examples of CDC handler implementations, see |
| 94 | +:github:`the source code for the prebuilt CDC handlers <mongodb/mongo-kafka/tree/master/src/main/java/com/mongodb/kafka/connect/sink/cdc>`. |
| 95 | + |
| 96 | +How to Use Your CDC Handler |
| 97 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 98 | + |
| 99 | +To configure your sink connector to use your custom CDC Handler, you must perform the |
| 100 | +following actions: |
| 101 | + |
| 102 | +#. Compile your custom CDC handler class to a JAR file. |
| 103 | + |
| 104 | +#. Add the compiled JAR to the classpath/plugin path for your Kafka workers. |
| 105 | + For more information about plugin paths, see the `Confluent documentation |
| 106 | + <https://docs.confluent.io/current/connect/managing/community.html>`__. |
| 107 | + |
| 108 | + .. note:: |
| 109 | + |
| 110 | + Kafka Connect loads plugins in isolation. When you deploy a custom write |
| 111 | + strategy, both the connector JAR and the CDC handler |
| 112 | + JAR should be on the same path. Your paths should resemble the following: |
| 113 | + |
| 114 | + | ``<plugin.path>/mongo-kafka-connect/mongo-kafka-connect-all.jar`` |
| 115 | + | ``<plugin.path>/mongo-kafka-connect/custom-CDC-handler.jar`` |
| 116 | + |
| 117 | + To learn more about {+kc+} plugins, see |
| 118 | + `this guide from Confluent <https://docs.confluent.io/home/connect/userguide.html#installing-kconnect-plugins>`__. |
| 119 | + |
| 120 | +#. Specify your custom class in the ``change.data.capture.handler`` |
| 121 | + :ref:`configuration setting <kafka-sink-properties>`. |
| 122 | + |
| 123 | +To learn how to compile a class to a JAR file, |
| 124 | +`see this guide from Oracle <https://docs.oracle.com/javase/tutorial/deployment/jar/build.html>`__. |
4 | 125 |
|
5 |
| -TODO: |
|
0 commit comments