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

Fix/threads #304

Merged
merged 4 commits into from
Nov 28, 2023
Merged
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,6 +1,6 @@
package ca.bc.gov.educ.penreg.api.service;

import ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchMultipleLocalID;
import ca.bc.gov.educ.penreg.api.exception.PenRegAPIRuntimeException;
import ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchMultiplePen;
import ca.bc.gov.educ.penreg.api.model.v1.Saga;
import ca.bc.gov.educ.penreg.api.model.v1.SagaEvent;
Expand Down Expand Up @@ -93,12 +93,17 @@ public Saga createSagaRecord(final Saga saga) {
@Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(multiplier = 2, delay = 2000))
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateAttachedSagaWithEvents(final Saga saga, final SagaEvent sagaEvent) {
saga.setUpdateDate(LocalDateTime.now());
this.getSagaRepository().save(saga);
val result = this.getSagaEventRepository()
.findBySagaAndSagaEventOutcomeAndSagaEventStateAndSagaStepNumber(saga, sagaEvent.getSagaEventOutcome(), sagaEvent.getSagaEventState(), sagaEvent.getSagaStepNumber() - 1); //check if the previous step was same and had same outcome, and it is due to replay.
if (result.isEmpty()) {
this.getSagaEventRepository().save(sagaEvent);
try {
saga.setUpdateDate(LocalDateTime.now());
this.getSagaRepository().save(saga);
val result = this.getSagaEventRepository()
.findBySagaAndSagaEventOutcomeAndSagaEventStateAndSagaStepNumber(saga, sagaEvent.getSagaEventOutcome(), sagaEvent.getSagaEventState(), sagaEvent.getSagaStepNumber() - 1); //check if the previous step was same and had same outcome, and it is due to replay.
if (result.isEmpty()) {
this.getSagaEventRepository().save(sagaEvent);
}
} catch (Exception e) {
log.error("updateAttachedSagaWithEvents failed for PenRequestBatchId :: {}, SagaId :: {}, SagaEventState :: {}, Error :: {}", saga.getPenRequestBatchID(), saga.getSagaId(), sagaEvent.getSagaEventState(), e);
throw new PenRegAPIRuntimeException(e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ PARSER_CONFIG="
"

THREADS_MIN_SUBSCRIBER=4
THREADS_MAX_SUBSCRIBER=8
THREADS_MAX_SUBSCRIBER=6
SAGAS_MAX_PENDING=100
SAGAS_MAX_PARALLEL=100

Expand Down