Last active
June 26, 2020 16:49
-
-
Save TylerPachal/faf51ce816da8e59ac72d2a7b80ca565 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the "top-level" function for my application | |
def handle_kafka_message(msg) do | |
# Try to do the processing | |
:ok = process(msg) | |
:ok = acknowledge(msg) | |
# Use catch/2 to handle errors, and send message to DLQ | |
catch kind, error -> | |
Datadog.emit("process_message_failure") | |
Logger.error(""" | |
Unexpected error occurred, sending message to DLQ. | |
Kind: #{kind} | |
Error: #{error} | |
""") | |
:ok = send_to_dlq(msg) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment