In MassTransit while using transport like RabbitMQ when an exception is thrown, the message goes into queue queue_name_error
. But using Kafka, there is no topic with _error
suffix, nor similar queue on supporting transport. How to handle exceptions properly using Kafka with MassTransit, and where erroneous messages can be found?
Asked
Active
Viewed 870 times
0

Rafał Ryszkowski
- 365
- 2
- 15
1 Answers
2
Since Kafka (and Azure Event Hub) are essentially log files with a fancy API, there is no need for an _error queue, as there are no queues anyway. There are no dead letters either. So the built-in error handling of MassTransit that moves faulted messages to the _error doesn't apply (nor does it make sense).
You can use the retry middleware (UseMessageRetry, etc.) with topic endpoints, to handle transient exceptions. You can also log the offset of poison messages to deal with them. The offset doesn't change, the messages remain in the topic until the expiration is reached.

Chris Patterson
- 28,659
- 3
- 47
- 59
-
Hi Chris, I can log the offset, partition, topic of the fault message, but how can I have the raw data to check the exception then fix that bug? – Khai Nguyen Oct 01 '22 at 14:29
-
You can read the raw data from Kafka at that topic, partition, and offset. – Chris Patterson Oct 02 '22 at 00:03