Overview
Use the following configuration settings to specify how the MongoDB Kafka sink connector handles errors and to configure the dead letter queue.
For a list of sink connector configuration settings organized by category, see the guide on Sink Connector Configuration Properties.
Settings
Name | Description |
|---|---|
mongo.errors.tolerance | Type: string |
mongo.errors.log.enable | Type: boolean |
errors.log.include.messages | Type: boolean |
errors.deadletterqueue.topic.name | Type: string |
errors.deadletterqueue.context.headers.enable | Type: boolean |
errors.deadletterqueue.topic.replication.factor | Type: integer |
Bulk Write Exceptions
The connector can report the following exceptions to your dead letter queue as context headers when performing bulk writes:
Name | Description | |
|---|---|---|
| Description: This class outputs the error in the following format: The fields in the preceding message contain the following information:
| |
| Description: This class outputs the error in the following format: The fields in the preceding message contain the following information:
| |
| Description:
To learn how to set the connector to perform unordered bulk
write operations, see the Connector Message Processing Properties page. This exception produces no message. |
To enable bulk write exception reporting to the dead letter queue, use the following connector configuration:
errors.tolerance=all errors.deadletterqueue.topic.name=<name of topic to use as dead letter queue> errors.deadletterqueue.context.headers.enable=true
Dead Letter Queue Configuration Example
Apache Kafka version 2.6 added support for handling errant records. The Kafka connector automatically sends messages that it cannot process to the dead letter queue. Once on the dead letter queue, you can inspect the errant records, update them, and resubmit them for processing.
The following is an example configuration for enabling the dead letter queue topic example.deadletterqueue. This configuration specifies that the dead letter queue and log file should record invalid messages, and that the dead letter queue messages should include context headers.
mongo.errors.tolerance=all mongo.errors.log.enable=true errors.log.include.messages=true errors.deadletterqueue.topic.name=example.deadletterqueue errors.deadletterqueue.context.headers.enable=true
To learn more about dead letter queues, see Write Errors and Errant Messages to a Topic.