Skip to content

Commit

Permalink
Catch errors parsing broker message headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wasdennnoch committed Dec 7, 2024
1 parent 88f1fa2 commit 58b4921
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ class RabbitConnection(
body: ByteArray
) {
val key = envelope.routingKey ?: ""
val value = String(body)
val headers = BrokerMessageHeaders(properties.headers.mapValues { it.value.toString() })
dispatchIncomingMessage(topic, key, value, headers)
try {
val value = String(body)
val headers = BrokerMessageHeaders(properties.headers.mapValues { it.value.toString() })
dispatchIncomingMessage(topic, key, value, headers)
} catch (e: Exception) {
log.error("Error handling incoming broker message in topic $topic, dropping message", e)
}
channel.basicAck(envelope.deliveryTag, false)
}

Expand Down

0 comments on commit 58b4921

Please sign in to comment.