The batch mode is working fine as i am able to receive the msgs as batch and publish as batch.
Now, i am trying to manually acknowledge the messages. If no exception, update the database with success and then accept the message. Else, update the DB with error and then requeue the message.
Function<Message<List<?>>, Collection>> receiveMessage()
return batchMsg → {
List<?> batchedPayloads = batchMsg.getPayload();
System. out .println("size " + batchedPayloads.size());
List<Map<String, Object>> batchedHeaders =
(List<Map<String, Object>>)
batchMsg.getHeaders().get(SolaceBinderHeaders. BATCHED_HEADERS );
AcknowledgmentCallback ackCallback =
StaticMessageHeaderAccessor. getAcknowledgmentCallback (batchMsg);
ackCallback.noAutoAck();
//calling the method to do business logic
try { List<> returnObjectList = method();
if (CollectionUtils. isNotEmpty (returnObjectList ))
{ AckUtils. accept (ackCallback);
return returnObjectList; }
} catch (Exception e) {
AckUtils. requeue (ackCallback);
return null;
}
}
application-default.properties
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.max-attempts = 3
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.back-off-initial-interval = 2000
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.back-off-max-interval = 30000
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.back-off-multiplier = 2
spring.cloud.stream.bindings.receiveMessage-in-0.consumer.default-retryable = true
The retry is happening 3 times , but the queue is cleared. Please suggest if the above implementation is fine.