Skip to content

Commit

Permalink
added recovery-ko by sesionId
Browse files Browse the repository at this point in the history
  • Loading branch information
aomegax committed Nov 13, 2024
1 parent 36c7715 commit 15976a3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentByP
}
}

@Operation(summary = "Execute reconciliation for OK receipts by sessionId.", description = "Execute reconciliation of all receipts related to the sessionIds of the request", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@Operation(summary = "Execute reconciliation for OK receipts by sessionId.", description = "Execute reconciliation of all OK receipts related to the sessionIds of the request", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Reconciliation scheduled")
})
@PostMapping(value = "/sessionIds/ok")
public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentBySessionId(@RequestBody RecoveryReceiptBySessionIdRequest request) {
public ResponseEntity<RecoveryReceiptReportResponse> recoverOkReceiptToBeReSentBySessionId(@RequestBody RecoveryReceiptBySessionIdRequest request) {
try {
log.debug("Invoking API operation recoverReceiptToBeReSentBySessionId - args: {}", sanitizeInput(request.toString()));
return ResponseEntity.ok(recoveryService.recoverReceiptOkToBeReSentBySessionIds(request));
Expand All @@ -150,4 +150,23 @@ public ResponseEntity<RecoveryReceiptReportResponse> recoverReceiptToBeReSentByS
throw ex;
}
}

@Operation(summary = "Execute reconciliation for KO receipts by sessionId.", description = "Execute reconciliation of all KO receipts related to the sessionIds of the request", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Recovery"})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Reconciliation scheduled")
})
@PostMapping(value = "/sessionIds/ko")
public ResponseEntity<RecoveryReceiptReportResponse> recoverKoReceiptToBeReSentBySessionId(@RequestBody RecoveryReceiptBySessionIdRequest request) {
try {
log.debug("Invoking API operation recoverReceiptToBeReSentBySessionId - args: {}", sanitizeInput(request.toString()));
return ResponseEntity.ok(recoveryService.recoverReceiptKoToBeReSentBySessionIds(request));
} catch (Exception ex) {
String operationId = MDC.get(Constants.MDC_OPERATION_ID);
log.error(String.format("GenericException: operation-id=[%s]", operationId != null ? operationId : "n/a"), ex);
AppException appException = new AppException(ex, AppErrorCodeMessageEnum.ERROR, ex.getMessage());
ErrorResponse errorResponse = errorUtil.forAppException(appException);
log.error("Failed API operation recoverReceiptToBeReSentBySessionId - error: {}", errorResponse);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum InternalStepStatus {
RT_SEND_RESCHEDULING_FAILURE,
RT_SEND_RESCHEDULING_REACHED_MAX_RETRIES,
RT_SEND_RESCHEDULING_SUCCESS,
RT_RECONCILIATION_PROCESS,
RT_START_RECONCILIATION_PROCESS,
RT_END_RECONCILIATION_PROCESS,
RT_DEAD_LETTER_SAVED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,24 @@ public RecoveryReceiptReportResponse recoverReceiptOkToBeReSentBySessionIds(Reco
}
}

@Transactional
public RecoveryReceiptReportResponse recoverReceiptKoToBeReSentBySessionIds(RecoveryReceiptBySessionIdRequest request) {
List<Pair<String, String>> receiptStatus = new ArrayList<>();
try {
for (String sessionId : request.getSessionIds()) {
receiptService.sendRTKoFromSessionId(sessionId, InternalStepStatus.RT_RECONCILIATION_PROCESS);
receiptStatus.add(Pair.of(sessionId, "SCHEDULED"));
}

return RecoveryReceiptReportResponse.builder()
.receiptStatus(receiptStatus)
.build();
}
catch (Exception e) {
throw new AppException(AppErrorCodeMessageEnum.ERROR, "Problem with KO receipt");
}
}

public RecoveryReceiptReportResponse recoverReceiptToBeReSentByPartition(RecoveryReceiptByPartitionRequest request) {

List<String> receiptsIds = request.getPartitionKeys().stream()
Expand Down

0 comments on commit 15976a3

Please sign in to comment.