Skip to content

Commit 7cac5ec

Browse files
Fixes for unique saga result
1 parent e6f5d0b commit 7cac5ec

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/events/EventHandlerService.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ public void handleUpdateDemogEvent(final Event event) throws JsonProcessingExcep
8080
log.trace(EXECUTION_IS_NOT_REQUIRED, event);
8181
return;
8282
}
83-
val saga = this.updateStudentDownstreamOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(updateStudentSagaData.getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
84-
log.debug("Starting updateStudentDownstreamOrchestrator orchestrator :: {}", saga);
85-
this.updateStudentDownstreamOrchestrator.startSaga(saga);
83+
try {
84+
val saga = this.updateStudentDownstreamOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(updateStudentSagaData.getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
85+
log.debug("Starting updateStudentDownstreamOrchestrator orchestrator :: {}", saga);
86+
this.updateStudentDownstreamOrchestrator.startSaga(saga);
87+
}catch(Exception e){
88+
//This will happen occasionally when we have multiple messages hitting our pods
89+
log.debug("Skipping processing on student {} :: saga already exists :: exception was: {}", updateStudentSagaData.getSdcSchoolCollectionStudentID(), e.getMessage());
90+
}
8691
}
8792
}
8893

@@ -95,9 +100,14 @@ public void handleUpdateStudentStatusEvent(final Event event) throws JsonProcess
95100
log.trace(EXECUTION_IS_NOT_REQUIRED, event);
96101
return;
97102
}
98-
val saga = this.updateStudentStatusOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(updateStudentSagaData.getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
99-
log.debug("Starting updateStudentStatusOrchestrator orchestrator :: {}", saga);
100-
this.updateStudentStatusOrchestrator.startSaga(saga);
103+
try {
104+
val saga = this.updateStudentStatusOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(updateStudentSagaData.getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
105+
log.debug("Starting updateStudentStatusOrchestrator orchestrator :: {}", saga);
106+
this.updateStudentStatusOrchestrator.startSaga(saga);
107+
}catch(Exception e){
108+
//This will happen occasionally when we have multiple messages hitting our pods
109+
log.debug("Skipping processing on student {} :: saga already exists :: exception was: {}", updateStudentSagaData.getSdcSchoolCollectionStudentID(), e.getMessage());
110+
}
101111
}
102112
}
103113

@@ -110,9 +120,14 @@ public void handleMigrateStudentEvent(final Event event) throws JsonProcessingEx
110120
log.trace(EXECUTION_IS_NOT_REQUIRED, event);
111121
return;
112122
}
113-
val saga = this.sdcStudentMigrationOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(sdcStudentSagaData.getSdcSchoolCollectionStudent().getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
114-
log.debug("Starting updateStudentDownstreamOrchestrator orchestrator :: {}", saga);
115-
this.sdcStudentMigrationOrchestrator.startSaga(saga);
123+
try {
124+
val saga = this.sdcStudentMigrationOrchestrator.createSaga(event.getEventPayload(), UUID.fromString(sdcStudentSagaData.getSdcSchoolCollectionStudent().getSdcSchoolCollectionStudentID()), null, ApplicationProperties.STUDENT_DATA_COLLECTION_API, null);
125+
log.debug("Starting updateStudentDownstreamOrchestrator orchestrator :: {}", saga);
126+
this.sdcStudentMigrationOrchestrator.startSaga(saga);
127+
}catch(Exception e){
128+
//This will happen occasionally when we have multiple messages hitting our pods
129+
log.debug("Skipping processing on student {} :: saga already exists :: exception was: {}", sdcStudentSagaData.getSdcSchoolCollectionStudent().getSdcSchoolCollectionStudentID(), e.getMessage());
130+
}
116131
}
117132
}
118133
}

0 commit comments

Comments
 (0)