您可以通过确认来实现
@SqsListener(value = "${queue.res-notification}",deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void receiveMessage(@NotificationMessage String message,@NotificationSubject String subject,Acknowledgment acknowledgment,@Header("ApproximateReceiveCount") final int receiveCount) {
try {
if(<some condition>){
acknowledgment.acknowledge(); // this will delete the message
}else{
//do not acknowledge so that message will not be deleted and stays in the queue for new round of reading
}
} catch (Exception e) {
log.error("Error reading notification ",e);
}
}
本文链接:https://www.f2er.com/3153718.html