-
Notifications
You must be signed in to change notification settings - Fork 1
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
retry template for rest template #145
retry template for rest template #145
Conversation
Signed-off-by: Viet Nguyen <[email protected]>
@@ -125,7 +125,6 @@ void testExtractPOrganisationVocabLabelsFromThemes() throws IOException { | |||
@Test | |||
void testProcessParameterVocabs() throws IOException, JSONException { | |||
// read from ARDC | |||
|
|||
List<VocabModel> parameterVocabsFromArdc = ardcVocabService.getVocabTreeFromArdcByType(VocabApiPaths.PARAMETER_VOCAB); | |||
|
|||
// read from Elastic search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read from Elastic search
always hit no documents found exception, I found that because there are nothing to be indexed into the test vocabs index.
When starting the app in non-test mode, everything is fine, the @PostConstruct
method in the vocab utils bean successfully indexed the fetched vocabs into the vocabs index.
When in test mode, the populateVocabsData
method is triggered but the subsequent processes didn't wait for fetched vocabs data, indexAllVocabs();
method is called before vocabs are fully fetched...even with synchronous approach.
I tried to create 2 method versions of populating vocabs data (async - this for running in the background and not blocking the app to start, and sync - primarily for dealing with the test issues) they all ended up the same...read from Elastic search
hit no docs exception, and logs of both showed that indexAllVocabs()
being called premature.
E.g
2024-09-30 09:42:49.090 INFO 349679 --- [ main] a.o.a.e.u.VocabsIndexUtils : Initialising test-vocabs-index synchronously for test profile
2024-09-30 09:42:49.092 INFO 349679 --- [ main] a.o.a.e.s.VocabServiceImpl : Starting fetching vocabs data process synchronously...
2024-09-30 09:42:49.098 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : getVocabLeafNodes -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-discovery-parameter-vocabulary/version-1-6/concept.json
2024-09-30 09:42:49.104 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : Query api -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-parameter-category-vocabulary/version-2-1/concept.json
2024-09-30 09:42:49.106 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : getVocabLeafNodes -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-platform-vocabulary/version-6-1/concept.json
2024-09-30 09:42:49.106 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : Query api -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-platform-category-vocabulary/version-1-2/concept.json
2024-09-30 09:42:49.107 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : getVocabLeafNodes -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-organisation-vocabulary/version-2-5/concept.json
2024-09-30 09:42:49.107 DEBUG 349679 --- [ main] a.o.a.a.s.ArdcVocabServiceImpl : Query api -> https://vocabs.ardc.edu.au/repository/api/lda/aodn/aodn-organisation-category-vocabulary/version-2-5/concept.json
2024-09-30 09:42:49.293 INFO 349679 --- [ main] a.o.a.e.s.ElasticSearchIndexService : Creating index: test-vocabs-index
2024-09-30 09:42:50.974 INFO 349679 --- [ main] a.o.a.e.s.ElasticSearchIndexService : CreateIndexResponse: {"index":"test-vocabs-index","shards_acknowledged":true,"acknowledged":true}
2024-09-30 09:42:50.975 INFO 349679 --- [ main] a.o.a.e.s.VocabServiceImpl : Indexing all vocabs to test-vocabs-index
2024-09-30 09:42:50.975 ERROR 349679 --- [ main] a.o.a.e.s.VocabServiceImpl : No vocabs to be indexed, nothing to index
(expect to take some minutes for stuff in ArdcVocabServiceImpl
to finish, before attempting to index the fetched data ).
Can you please help, I tried everything I could (countdown latch etc. ) but so far no luck @utas-raymondng , thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request change
@@ -31,6 +33,7 @@ public class ArdcVocabServiceImpl implements ArdcVocabService { | |||
|
|||
public ArdcVocabServiceImpl(RestTemplate restTemplate) { | |||
this.restTemplate = restTemplate; | |||
this.retryTemplate = new RetryTemplate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you should do it like this
- You already create the retryTemplate using @bean
- The ArdcVocabServiceImpl is create in the config so all you need to do it add the parameter in the creation so it autowrite the RetryTemplate and then you can set it via the constructore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.