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

feat: use default ack mode for recommendation indexes and throw excep… #478

Merged
merged 8 commits into from
Dec 8, 2023

Conversation

CaiWillis
Copy link
Contributor

…tions appropriately

TIS21-5152: Process Change Stream messages quicker

…tions appropriately

TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
TIS21-5152: Process Change Stream messages quicker
@@ -50,8 +46,7 @@ public void saveRecommendationView(RecommendationView dataToSave) {
try {
recommendationElasticSearchRepository.save(dataToSave);
} catch (Exception ex) {
LOG.error("Exception in `saveRecommendationViews` (GmcId: {}; PersonId: {}): {}",
dataToSave.getGmcReferenceNumber(), dataToSave.getTcsPersonId(), ex);
throw new DoctorIndexUpdateException(ex.getMessage(), ex);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is even needed?

@@ -50,8 +46,7 @@ public void saveRecommendationView(RecommendationView dataToSave) {
try {
recommendationElasticSearchRepository.save(dataToSave);
} catch (Exception ex) {
LOG.error("Exception in `saveRecommendationViews` (GmcId: {}; PersonId: {}): {}",
dataToSave.getGmcReferenceNumber(), dataToSave.getTcsPersonId(), ex);
throw new DoctorIndexUpdateException(ex.getMessage(), ex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think we should catch and add information, you've done the great thing of including the cause ex. That means the message will be included in any stacktrace etc. and you don't need to use it here. I'd create something specific to the context.

The stacktrace will show that it is thrown from RecommendationElasticSearchService.saveRecommendationView:49 but this message will be more visible so I like that the message logged included information about what was happening.
"Failed to save a recommendation view." is better than e.g. "Broken pipe (Write failed)", with or without extending that to include "Failed to save a recommendation view for doctor (GMC: %s, Person ID: %d)"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've also not certain about whether we should wrap any Exception. I think we'll be ok with the cause being thrown.

TIS21-5152: Process Change Stream messages quicker
@CaiWillis
Copy link
Contributor Author

Do we want to include the retry config in the PR? If something does fail, the recommendation service will generate a lot of logs

Copy link

sonarcloud bot commented Dec 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.21) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@JosephKelly
Copy link
Contributor

Do we want to include the retry config in the PR? If something does fail, the recommendation service will generate a lot of logs

It's worth looking at the retry config now but I'd like to be guided by whether you think this PR as-is forms a change that can run reliably. I'm happy it does represent an improvement to the reliability of the recommendation service.

@CaiWillis CaiWillis merged commit 4215d5e into main Dec 8, 2023
3 checks passed
@CaiWillis CaiWillis deleted the feat/useDefaultAckModeForRecommendationIndexUpdates branch December 8, 2023 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants