Supporting DLQ in batch mode (#2649)

* Supporting DLQ in batch mode

Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2317

* PR review

Co-authored-by: Gary Russell <grussell@vmware.com>

---------

Co-authored-by: Gary Russell <grussell@vmware.com>

Polish to previous commit
This commit is contained in:
Soby Chacko
2023-02-13 12:05:28 -05:00
committed by Soby Chacko
parent 0c74f2f460
commit 13bb288499
3 changed files with 213 additions and 137 deletions

View File

@@ -380,6 +380,10 @@ The size of the batch is controlled by Kafka consumer properties `max.poll.recor
Bear in mind that batch mode is not supported with `@StreamListener` - it only works with the newer functional programming model.
Starting with version `4.0.2`, the binder supports DLQ capabilities when consuming in batch mode.
Keep in mind that, when using DLQ on a consumer binding that is in batch mode, all the records received from the previous poll will be delivered to the DLQ topic.
IMPORTANT: Retry within the binder is not supported when using batch mode, so `maxAttempts` will be overridden to 1.
You can configure a `DefaultErrorHandler` (using a `ListenerContainerCustomizer`) to achieve similar functionality to retry in the binder.
You can also use a manual `AckMode` and call `Ackowledgment.nack(index, sleep)` to commit the offsets for a partial batch and have the remaining records redelivered.