Skip to content

Commit c5d2fef

Browse files
biniona-mongodbschmalliso
authored andcommitted
(DOCSP-20141) Write MongoDB Errors to DLQ (#224)
1 parent 16d3e4b commit c5d2fef

File tree

4 files changed

+125
-41
lines changed

4 files changed

+125
-41
lines changed

snooty.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ kc = "Kafka Connect"
1111
avro = "Apache Avro"
1212
avro-short = "Avro"
1313
kafka-connect = "Confluent Kafka Connect"
14-
connector_version="1.6"
15-
connector_patch_version="1"
14+
connector_version="1.7"
15+
connector_patch_version="0"
1616
connector_driver_version="4.3"
17-
connector_version_github_tag="r{+connector_version+}.{+connector_patch_version+}"
17+
connector_version_github_tag="master"
1818
sink-connector="MongoDB Kafka sink connector"
1919
source-connector="MongoDB Kafka source connector"
2020
connector_driver_url_base="https://docs.mongodb.com/drivers/java/sync/v{+connector_driver_version+}/"
21+
connector_driver_api_doc_url_base="https://mongodb.github.io/mongo-java-driver/{+connector_driver_version+}/"
2122
pipeline-size = "2.4 GB"
2223
stable-api = "Stable API"
2324
default-heartbeat-topic = "__mongodb_heartbeats"
25+
26+
write-exception-version="1"
27+
write-concern-exception-version="1"

source/sink-connector/configuration-properties/error-handling.txt

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Settings
6565

6666
| When set to ``true``, the connector logs both "tolerated" and
6767
"not tolerated" errors.
68-
| When set to ``false``, the connector logs "not tolertaed" errors.
68+
| When set to ``false``, the connector logs "not tolerated" errors.
6969

7070
.. note::
7171

@@ -105,8 +105,11 @@ Settings
105105
| **Description:**
106106
| Whether the connector should include context headers when it
107107
writes messages to the dead letter queue.
108-
| For more information about the dead letter queue, see the
108+
| To learn more about the dead letter queue, see the
109109
:ref:`Dead Letter Queue Configuration Example <sink-dead-letter-queue-configuration-example>`.
110+
| To learn about the exceptions the connector defines and
111+
reports through context headers, see the
112+
:ref:`<sink-configuration-error-handling-dlq-errors>` section.
110113
|
111114
| **Default:** ``false``
112115
| **Accepted Values**: ``true`` or ``false``
@@ -126,6 +129,114 @@ Settings
126129

127130
.. _sink-configuration-error-handling-table-end:
128131

132+
.. _sink-configuration-error-handling-dlq-errors:
133+
134+
Bulk Write Exceptions
135+
---------------------
136+
137+
The connector can report the following exceptions to your dead letter queue
138+
as context headers when performing bulk writes:
139+
140+
.. list-table::
141+
:header-rows: 1
142+
:widths: 34 66
143+
144+
* - Name
145+
- Description
146+
147+
* - | ``WriteException``
148+
- | **Description:**
149+
| Contains details of a
150+
`BulkWriteError <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/BulkWriteError.html>`__
151+
your connector encountered.
152+
|
153+
| **Message Format:**
154+
155+
This class outputs the error in the following format:
156+
157+
.. code-block:: none
158+
159+
v=%d, code=%d, message=%s, details=%s
160+
161+
The fields in the preceding message contain the following information:
162+
163+
- ``v``: The version of the ``WriteException`` message format.
164+
This field helps parse the messages produced by this exception.
165+
For version {+connector_version+} of the connector, the version of the
166+
message format is {+write-exception-version+}.
167+
- ``code``: The code associated with the error. To learn more see the
168+
`getCode() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/WriteError.html#getCode()>`__
169+
method documentation.
170+
- ``message``: The message associated with the error. To learn more, see the
171+
`getMessage() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/WriteError.html#getMessage()>`__
172+
method documentation.
173+
- ``details``: The details associated with the error in JSON format. To
174+
learn more, see the following method documentation:
175+
176+
- `getDetails() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/WriteError.html#getDetails()>`__
177+
- `toJson() <{+connector_driver_api_doc_url_base+}apidocs/bson/org/bson/BsonDocument.html#toJson()>`__
178+
179+
* - | ``WriteConcernException``
180+
- | **Description:**
181+
| Contains details of a
182+
`WriteConcernError <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/WriteConcernError.html>`__
183+
your connector encountered.
184+
|
185+
| **Message Format:**
186+
187+
This class outputs the error in the following format:
188+
189+
.. code-block:: none
190+
191+
v=%d, code=%d, codeName=%d, message=%s, details=%s
192+
193+
The fields in the preceding message contain the following information:
194+
195+
- ``v``: The version of the ``WriteConcernException`` message format.
196+
This field helps parse the messages produced by this exception.
197+
For version {+connector_version+} of the
198+
connector, the version of the message format is
199+
{+write-concern-exception-version+}.
200+
- ``code``: The code associated with the error. To learn more see the
201+
`getCode() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/WriteConcernError.html#getCode()>`__
202+
method documentation.
203+
- ``codeName``: The code name associated with the error. To learn more, see the
204+
`getCodeName() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/WriteConcernError.html#getCode()>`__
205+
method documentation.
206+
- ``message``: The message associated with the error. To learn more, see the
207+
`getMessage() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/WriteConcernError.html#getMessage()>`__
208+
method documentation.
209+
- ``details``: The details associated with the error in JSON format. To
210+
learn more, see the following method documentation:
211+
212+
- `getDetails() <{+connector_driver_api_doc_url_base+}apidocs/mongodb-driver-core/com/mongodb/bulk/WriteConcernError.html#getDetails()>`__
213+
- `toJson() <{+connector_driver_api_doc_url_base+}apidocs/bson/org/bson/BsonDocument.html#toJson()>`__
214+
215+
* - | ``WriteSkippedException``
216+
- | **Description:**
217+
| Informs that MongoDB did not attempt the write of a ``SinkRecord`` as part of
218+
the following scenario:
219+
220+
#. The connector sends an ordered bulk write operation to MongoDB
221+
#. MongoDB fails to process a write operation in the ordered bulk write
222+
#. MongoDB does not attempt to perform all subsequent write operations in the ordered bulk write
223+
224+
| To learn how to set the connector to perform unordered bulk
225+
write operations, see the :ref:`<sink-configuration-message-processing>` page.
226+
| **Message Format:**
227+
228+
This exception produces no message.
229+
230+
To enable bulk write exception reporting to the dead letter queue, use the
231+
following connector configuration:
232+
233+
.. code-block:: properties
234+
:emphasize-lines: 3
235+
236+
errors.tolerance=all
237+
errors.deadletterqueue.topic.name=<name of topic to use as dead letter queue>
238+
errors.deadletterqueue.context.headers.enable=true
239+
129240
.. _sink-dead-letter-queue-configuration-example:
130241

131242
Dead Letter Queue Configuration Example

source/sink-connector/configuration-properties/mongodb-connection.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ Settings
5151
| **Default**: ``mongodb://localhost:27017``
5252
| **Accepted Values**: A MongoDB connection URI string
5353

54-
* - | **max.num.retries**
55-
- | **Type:** int
56-
|
57-
| **Description:**
58-
| The number of retries to attempt when encountering write errors to MongoDB.
59-
|
60-
| **Default**: ``1``
61-
| **Accepted Values**: An integer
62-
63-
* - | **retries.defer.timeout**
64-
- | **Type:** int
65-
|
66-
| **Description:**
67-
| Amount of time (in milliseconds) to defer a retry attempt.
68-
|
69-
| **Default**: ``5000``
70-
| **Accepted Values**: An integer
71-
7254
* - **server.api.version**
7355
- | **Type:** string
7456
|

source/sink-connector/fundamentals/error-handling-strategies.txt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,15 @@ errant message, use the following option:
111111

112112
errors.deadletterqueue.context.headers.enable=true
113113

114-
.. important:: Bulk Write Errors
115-
116-
If an error occurs while performing a bulk write to MongoDB, you must specify
117-
the following to log any information about the error to a dead letter queue:
118-
119-
.. code-block:: properties
120-
121-
errors.tolerance=all
122-
mongo.errors.tolerance=none
123-
errors.deadletterqueue.topic.name=<name of topic to use as dead letter queue>
124-
125-
We will fix this special case soon. To track the status of this issue,
126-
see :issue:`this JIRA ticket <KAFKA-223>`.
127-
128-
For more information on the ``mongo.errors.tolerance`` option, see our
129-
section on :ref:`connector level options <kakfa-sink-connector-level>`.
130-
131-
For more information, see Confluent's guide on
114+
To learn more about dead letter queues, see Confluent's guide on
132115
`Dead Letter Queues <https://docs.confluent.io/cloud/current/connectors/dead-letter-queue.html#dead-letter-queue>`__.
133116

134117
To view another dead letter queue configuration example, see :ref:`<sink-dead-letter-queue-configuration-example>`.
135118

119+
To learn about the exceptions your connector defines and writes as context
120+
headers to the dead letter queue,
121+
see :ref:`<sink-configuration-error-handling-dlq-errors>`.
122+
136123
.. _kafka-sink-log-errors:
137124

138125
Log Errors

0 commit comments

Comments
 (0)