Skip to content

Instantly share code, notes, and snippets.

@TylerPachal
Last active June 26, 2020 16:49
Show Gist options
  • Save TylerPachal/faf51ce816da8e59ac72d2a7b80ca565 to your computer and use it in GitHub Desktop.
Save TylerPachal/faf51ce816da8e59ac72d2a7b80ca565 to your computer and use it in GitHub Desktop.
# 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