Retry and dead letter
A consumer that retries a locked row, dead-letters records that can never succeed with their original bytes, and the same inputs through a Camel route.
examples/13-retry-and-dead-letter/ reads OrderPlaced records from edp.orders.placed, reserves stock, retries a failure that can clear and sends the records that cannot succeed to edp.orders.placed-dlq. It accompanies Retry and dead letter.
It uses Quarkus, Hibernate ORM with Panache, Flyway, SmallRye Reactive Messaging with SmallRye Fault Tolerance, Camel Kafka for the comparison route, PostgreSQL and OpenTelemetry to the LGTM stack.
(cd examples/domain-model && mvn -B -q install)
cd examples/13-retry-and-dead-letter
mvn -B verify
./verify.sh
What to observe
- A truncated record is kept. It is on
edp.orders.placed-dlqwith the bytes that were sent, and its headers name the source topic and offset. - An invalid record is tried once. A quantity of 0 is dead-lettered without a retry, and the reason says why.
- A locked row is retried. The order is attempted again until the lock is released, then reserved.
- The record behind it waits. A valid order for another SKU is not read while the first is retried.
- The Camel route does the same. It dead-letters the same records with their original bytes, and no headers describe the failure.
Infrastructure
Kafka, PostgreSQL and the LGTM stack from examples/_infra, a one-shot container that creates the order topic and its dead letter topic with one partition each, and inventory-service. The compose project is edp-13.