Search code examples
spring-batchspring-rabbit

Spring Batch AmqpItemReader acknowledge


I have an issue when I want a return my data to a queue when my service is down, after reading batch with data. If I goos understood in amqp I can use acknowledge, but in spring bath documentation I don't see any information about that. Also, I check the source code for AmqpItemReader and I don't see any flow for acknowledge. Do I need to implement custom ItemReader with this flow or missed something?


Solution

  • The AmqpItemReader uses a simple RabbitTemplate.receive() operation which acks the message immediately, unless it is running in a transaction.

    The only way to control the acks is to use transactions (with a RabbitTransactionManager).

    The transaction manager will ack or requeue the message if the transaction is committed or rolled-back, respectively.