Capture changed data from CDC sources in a mapping
You can use MongoDB V2 Connector to write the changed data from a CDC source, such as Microsoft SQL Server CDC, and write the changed data to a MongoDB V2 target in a mapping. You can't write the changed data to MongoDB from a CDC source in a mapping in advanced mode.
When you configure a mapping, add the CDC sources and then run the associated mapping task to write the changed data to MongoDB. If you define a column as required in the MongoDB V2 target table, map a column in the CDC source to the required column in the MongoDB V2 target in the mapping before you run the task.
When the mapping task processes the changed data from a CDC source, MongoDB V2 Connector creates a state table in MongoDB. When the changed data is received from the CDC source, MongoDB V2 Connector uploads the changed data to the staging table. Then, it generates a Job_Id and writes the Job_Id to the state table along with the restart information.
The connector then merges the stage table with the actual target table in MongoDB. Each time you run the mapping task, MongoDB V2 Connector creates the state table, if it does not exist, to store the state information.
If you stop a CDC mapping task enabled with recovery strategy, or if it terminates unexpectedly, you can also restart it from the beginning of the task or resume it from where the task last ended from the job details page.
For more information about restarting and resuming a mapping task, see Tasks.
Restrictions
Consider the following restrictions when you capture the changed data from CDC sources:
Source or lookup object in a CDC mapping
You can use a MongoDB V2 target in a CDC mapping to write data from CDC sources. You can't use a MongoDB V2 source or lookup in a CDC mapping.
Target created at run time
You can't write data from a CDC source to a MongoDB V2 target created at run time.
Configuring a mapping task to read from a CDC source
You can use MongoDB V2 Connector to capture the changed data from a CDC source and write the changed data to a MongoDB V2 target.
To capture the changed data from a CDC source, you need to add the CDC source in the mapping, and then run the associated mapping task to write the changed data to the MongoDB V2 target. You can also configure multiple pipelines in a single mapping to write the captured changed data to a MongoDB V2 target.
When you configure a mapping to write the changed data from a CDC source to MongoDB, you can configure the following advanced properties in the MongoDB V2 Target transformation:
•Update Mode
•Pre Query
•Post Query
•Additional Properties
•Forward Rejected Rows
Step 1. Configure the source
Configure a Source transformation to read from a CDC source, such as Microsoft SQL Server CDC.
1In the Source transformation, specify a name and description in the general properties.
2In the Source tab, select any configured CDC connection and specify the required source properties.
It is recommended that the source object contains a primary key.
Step 2. Configure the target
Configure a Target transformation to write changed data from a CDC source to MongoDB.
You can only configure a single MongoDB V2 target transformation in a mapping to write changed data from a CDC source.
1On the Target tab, perform the following steps to configure the target properties:
aIn the Connection field, select the MongoDB V2 connection.
bIn the Object Type field, select the type of the target object.
cIn the Object field, select the required target object.
dIn the Operation field, select Data Driven.
Note:
Insert, update, upsert, and delete target operations are not applicable.
eConfigure the applicable advanced target properties for the CDC mode.
2On the Field Mapping tab, map the incoming fields to the target fields. You can manually map an incoming field to a target field or automatically map fields based on the field names.
If you define a column as required in the MongoDB V2 target table, map a column in the CDC source to the required column in the MongoDB V2 target in the mapping.
Step 3. Configure the mapping task
After you create a mapping, add the mapping to a mapping task, and configure the advanced properties. Run the associated mapping task to write the changed data to MongoDB.
1From the Actions menu, click New Mapping Task.
The New Mapping Task page appears.
2In the Definition tab, enter the task name and select the configured mapping.
3In the CDC Runtime tab, specify the required properties for the selected CDC source.
For more information about the CDC Runtime properties, see the source properties for the selected CDC source.
4In the Runtime Options tab, add the following properties in the Advanced Session Properties section:
aIn the Commit on End of File field, select the value of the property as No.
bIn the Commit Type field, select the value of the property as Source.
cIn the Recovery Strategy field, select the value of the property as Resume from last checkpoint.
5Click Save > Run the mapping task.
Alternatively, you can create a schedule that runs the mapping task on a recurring basis without manual intervention. You can define the schedule to minimize the time between mapping task runs. In Monitor, you can monitor the status of the logs after you run the task.
To improve performance, specify a higher commit interval for the Maximum Rows Per Commit property in the CDC Runtime page in the mapping task wizard. However, in case of failure, recovery takes more time for a higher commit interval.