Skip to content

Commit

Permalink
Merge pull request #304 from bcgov/fix/threads
Browse files Browse the repository at this point in the history
Fix/threads
  • Loading branch information
arcshiftsolutions authored Nov 28, 2023
2 parents 2bca81a + 06b0e2a commit 749edd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
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

0 comments on commit 749edd7

Please sign in to comment.