RED-6805: As Operation I want to see why downloads are in an ERROR state

added errorcause to repository
This commit is contained in:
yhampe 2024-01-15 12:21:00 +01:00
parent 0cfbdb3083
commit 4ccf355dcf
4 changed files with 12 additions and 4 deletions

View File

@ -60,6 +60,8 @@ public class DownloadStatusEntity {
OffsetDateTime lastDownload;
@Column
long fileSize;
@Column
String errorCause;
@ManyToOne(fetch = FetchType.EAGER)
DossierEntity dossier;

View File

@ -68,9 +68,11 @@ public class DownloadDLQMessageReceiver {
private void setDownloadFailed(String userId, String downloadId) {
String errorCause = "unknown error cause";
retryTemplate.execute(retryContext -> {
log.warn("Retrying {} time to set FAILED status for downloadJob userId: {} storageId: {}", retryContext.getRetryCount(), userId, downloadId);
downloadStatusPersistenceService.updateStatus(downloadId, DownloadStatusValue.FAILED);
downloadStatusPersistenceService.updateStatus(downloadId, DownloadStatusValue.FAILED,errorCause);
return null;
});
}
@ -79,7 +81,7 @@ public class DownloadDLQMessageReceiver {
retryTemplate.execute(retryContext -> {
log.warn("Retrying {} time to set FAILED status for downloadJob userId: {} storageId: {}", retryContext.getRetryCount(), userId, downloadId);
downloadStatusPersistenceService.updateStatus(downloadId, DownloadStatusValue.FAILED);
downloadStatusPersistenceService.updateStatus(downloadId, DownloadStatusValue.FAILED, errorCause);
return null;
});
}

View File

@ -65,9 +65,9 @@ public class DownloadStatusPersistenceService {
@Transactional
public void updateStatus(String storageId, DownloadStatusValue status) {
public void updateStatus(String storageId, DownloadStatusValue status, String errorCause) {
downloadStatusRepository.updateStatus(storageId, status);
downloadStatusRepository.updateStatusAndErrorCause(storageId, status, errorCause);
}

View File

@ -20,6 +20,10 @@ public interface DownloadStatusRepository extends JpaRepository<DownloadStatusEn
@Query("update DownloadStatusEntity ds set ds.status = :status where ds.storageId = :storageId")
int updateStatus(@Param("storageId") String storageId, @Param("status") DownloadStatusValue status);
@Query("update DownloadStatusEntity ds set ds.status = :status, ds.errorCause = :errorCause where ds.storageId = :storageId")
int updateStatusAndErrorCause(@Param("storageId") String storageId, @Param("status") DownloadStatusValue status, @Param("errorCause") String errorCause);
@Modifying
@Transactional
@Query("update DownloadStatusEntity ds set ds.status = :status where ds.storageId = :storageId and ds.status != :status")