Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Merge pull request #6 from miracum/store-error-message-in-headers-in-…
Browse files Browse the repository at this point in the history
…error-topic

fix: store the error description in message headers for the DLQ
  • Loading branch information
chgl authored May 30, 2021
2 parents 0991c87 + 51802bd commit 5614331
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ahd2fhir/kafka_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ async def send_consumer_message(consumer): # pragma: no cover
failed_topic=failed_topic,
)

headers = [("error", f"Mapping Error: {exc}".encode("utf8"))]

try:
await producer.send_and_wait(failed_topic, msg.value)
await producer.send_and_wait(
failed_topic, msg.value, key=msg.key, headers=headers
)
except Exception as error_topic_exc:
logger.error(
f"Failed to send message to error topic: {error_topic_exc}"
Expand Down

0 comments on commit 5614331

Please sign in to comment.