Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/not retryable hadler #340

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package it.pagopa.pn.paperchannel.middleware.db.dao.impl;

import it.pagopa.pn.paperchannel.config.AwsPropertiesConfig;
import it.pagopa.pn.paperchannel.encryption.DataEncryption;
import it.pagopa.pn.paperchannel.generated.openapi.server.v1.dto.InfoDownloadDTO;
import it.pagopa.pn.paperchannel.middleware.db.dao.PaperRequestErrorDAO;
import it.pagopa.pn.paperchannel.middleware.db.dao.common.BaseDAO;
import it.pagopa.pn.paperchannel.middleware.db.entities.PnRequestError;
import it.pagopa.pn.paperchannel.utils.Const;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient;
import software.amazon.awssdk.enhanced.dynamodb.model.QueryConditional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.pagopa.pn.paperchannel.utils.PnLogAudit;
import reactor.core.publisher.Mono;


public class NotRetryableErrorMessageHandler extends SendToDeliveryPushHandler {

private final PaperRequestErrorDAO paperRequestErrorDAO;
Expand All @@ -22,14 +23,16 @@ public Mono<Void> handleMessage(PnDeliveryRequest entity, PaperProgressStatusEve
PnAuditLogBuilder auditLogBuilder = new PnAuditLogBuilder();
PnLogAudit pnLogAudit = new PnLogAudit(auditLogBuilder);
pnLogAudit.addsBeforeDiscard(entity.getIun(), String.format("requestId = %s finish retry to External Channel", entity.getRequestId()));

return super.handleMessage(entity, paperRequest)
.doOnSuccess(pnRequestError -> {
paperRequestErrorDAO.created(entity.getRequestId(), entity.getStatusCode(), entity.getStatusDetail());
pnLogAudit.addsSuccessDiscard(entity.getIun(), String.format("requestId = %s finish retry to External Channel", entity.getRequestId()));
})
.then(Mono.defer(() ->
paperRequestErrorDAO.created(entity.getRequestId(), entity.getStatusCode(), entity.getStatusDetail())
.doOnSuccess(requestError ->
pnLogAudit.addsSuccessDiscard(entity.getIun(), String.format("requestId = %s finish retry to External Channel", entity.getRequestId()))
)
))
.doOnError(throwable -> pnLogAudit.addsFailDiscard(entity.getIun(), String.format("requestId = %s finish retry to External Channel", entity.getRequestId())))
.then();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.pagopa.pn.paperchannel.service.SqsSender;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import reactor.core.publisher.Mono;

import java.time.OffsetDateTime;
Expand Down Expand Up @@ -42,7 +43,7 @@ void handleMessageTest() {
.statusDateTime(instant)
.clientRequestTimeStamp(instant);

when(paperRequestErrorDAOMock.created("requestId", "statusCode", "statusDetails"))
when(paperRequestErrorDAOMock.created(Mockito.anyString(), Mockito.anyString(), Mockito.anyString()))
.thenReturn(Mono.just(new PnRequestError()));

assertDoesNotThrow(() -> handler.handleMessage(entity, paperRequest).block());
Expand Down