package jnpf.dmsService;
|
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Service;
|
|
/** Recovery consumes proven native terminal states; never expires a lease by age. */
|
@Service
|
@Slf4j
|
@RequiredArgsConstructor
|
public class DmsBusinessOccupancyTerminationJob {
|
private final DmsBusinessLifecycleGuard guard;
|
@Scheduled(cron="${dms.business-occupancy.termination-cron:0 * * * * ?}")
|
public void releaseEndedApplications() {
|
String after=null;
|
for(int page=0;page<100;page++) {
|
var rows=guard.terminationCandidates(after,100);
|
for(var row:rows) try { guard.releaseEnded(row); }
|
catch(RuntimeException error) { log.error("DMS terminal occupancy release failed tenant={} receipt={}",row.getTenantId(),row.getId(),error); }
|
if(rows.size()<100) return;
|
after=rows.get(rows.size()-1).getId();
|
}
|
}
|
}
|