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

reset errorcause when downloadstatus is ready
ensuring lenghth of errorcause will not exceed field length
This commit is contained in:
yhampe 2024-01-16 09:55:48 +01:00
parent 3f6c493e54
commit 5333db97ea
2 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,7 @@ public class DownloadDLQMessageReceiver {
private final DownloadStatusPersistenceService downloadStatusPersistenceService;
private final RetryTemplate retryTemplate;
private final ObjectMapper objectMapper;
private final static int MAX_ERROR_CAUSE_LENGTH = 1024;
@RabbitListener(queues = MessagingConfiguration.DOWNLOAD_COMPRESSION_DLQ)
@ -43,6 +44,7 @@ public class DownloadDLQMessageReceiver {
var downloadJob = objectMapper.readValue(failedMessage.getBody(), DownloadJob.class);
String errorCause = failedMessage.getMessageProperties().getHeader(X_ERROR_INFO_HEADER);
errorCause = errorCause.substring(0,MAX_ERROR_CAUSE_LENGTH-1);
if (errorCause == null) {
errorCause = "Error occured during download job!";
}

View File

@ -81,6 +81,10 @@ public class DownloadStatusPersistenceService {
@Transactional
public void updateStatus(DownloadStatusEntity entity, DownloadStatusValue statusValue, long fileSize) {
if(statusValue.equals(DownloadStatusValue.READY)) {
entity.setErrorCause("");
}
entity.setStatus(statusValue);
entity.setFileSize(fileSize);
downloadStatusRepository.save(entity);