-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Provide ability to disable/limit retries in batch listener when using DefaultAfterRollbackProcessor #2588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Forcing it to be To solve this problem, we should probably enhance the DARP to understand We could also provide recovery for other exceptions by recovering every record in the batch (again, like the Note that if you are only using DB transactions (and not publishing to Kafka as well as updating the DB in the listener), there is no need to make the container transactional. |
Yes, you are right. It will just limit retries. It will not be infinite
we always update DB in |
You don’t need Kafka transactions if you are not producing to Kafka in your listener. They have nothing to do with idempotent consumers, only exactly once semantics for Or, for atomically producing multiple records. |
We don't use Kafka transactions at all. We use DB transactions instead to implement idempotent consumer. Anyway, it does not matter which transactions to use there, the behavior of retries will be the same. So it would be nice to have proper retries in the batch listener with |
I agree; hence my comments above about enhancing the rollback processor. However, adding a transaction manager to the container is only intended for the use of Kafka transactions. You can use The container should never have a transaction manager if Kafka transactions are not being used. |
Hi, @garyrussell may i pick it up? |
sure you can! This is an Open Source project, so any contribution is welcome! |
spring-projectsGH-2588: ARBP support BatchListenerFailedException * add default function `processBatch` in AfterRollbackProcessor * support BatchListenerFailedException in DefaultAfterRollbackProcessor * Add unit tests
Resolves spring-projects#2588 * add default function `processBatch` in AfterRollbackProcessor * support BatchListenerFailedException in DefaultAfterRollbackProcessor * Add unit tests
spring-projectsGH-2588: ARBP support BatchListenerFailedException * support retry and recover in `DefaultAfterRollbackProcessor.processBatch` * add nextBackOff at `ListenerUtils` * fix assertThat `KafkaHeaders.DLT_ORIGINAL_OFFSET` at `TransactionalContainerTests.testMaxFailures`
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
…ckProcessor` deprecated transactionManager and add KafkaAwareTransactionManager at ContainerProperties, after remove transactionManager, change `KafkaMessageListenerContainer#transactionManager` type to PlatformTransactionManager
…ckProcessor` modify toString in `ContainerProperties`
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
…ckProcessor` deprecated transactionManager and add KafkaAwareTransactionManager at ContainerProperties, after remove transactionManager, change `KafkaMessageListenerContainer#transactionManager` type to PlatformTransactionManager * modify toString in `ContainerProperties`
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
…ckProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test
* support batch recoverable `DefaultAfterRollbackProcessor` * add method processBatch at `AfterRollbackProcessor` * add opt-in property `batchRecoverAfterRollback` at `ContainerProperties` * change format to `BatchListenerFailedException.getMessage` * add batch recoverable after rollback unit test * review fix * `what-new.adoc` and `annotation-error-handling.adoc` * add javadoc in `SeekUtils` and `AfterRollbackProcessor` * change `ListenerUtils.nextBackOff` public to default * change logger args to static string * @author classes. * fix adoc * poblish `AfterRollbackProcessor` * javadoc at `ContainerProperties` * fix review and fix test bug at DefaultAfterRollbackProcessorTests * add @test to DefaultAfterRollbackProcessorTests.testNoEarlyExitBackOff * polish TransactionalContainerTests * fix bug Tests at DefaultAfterRollbackProcessorTests method `testNoEarlyExitBackOff` and testEarlyExitBackOff
Expected Behavior
Configuration to disable/limit retries in the batch listener when using DB transactions and
DefaultAfterRollbackProcessor
Example of listener
@KafkaListener(topics = BATCH_TOPIC, batch = "true") {}
Current Behavior
Currently, the
DefaultAfterRollbackProcessor
retries the failing message infinitely if using batch listener with DB transactions.Context
The main problem if we forget to handle the failing message inside the listener then the failed message will stuck until we take some manual action to skip this message. That's why we would like to have a config to disable/limit retries at the configurations level.
I tried to find a way to disable retries for batch listeners but unsuccessfully.
new FixedBackOff(0, 0)
new DefaultAfterRollbackProcessor<>(deadLetterPublishingRecoverer, backOff);
The workaround can be to force to use
recoverable=true
always in order to limit retriesThe text was updated successfully, but these errors were encountered: