Reputation: 458
Say I have to perform an insert operation on a database, but before that I need to call a function(maybe more than one), that hits a url with the data to be inserted in DB, which returns values that dictate whether the data being held in my app, is eligible for insertion.
void func(DataToInsert data) {
Promise<ReceivedResponse> response = checkIfDataIsEligibleForInsertion(data));
response.then(result-> {
if(result.getoperationstatus().equals("FAILED")) {
// Log message
} else{
performInsertOp(data);
}
});
}
Promise<ReceivedResponse> checkIfDataIsEligibleForInsertion(DataToInsert data) {
// API call performed through an async httpclient and promise returned
}
I often get a gateway timeout. How do I avoid this and ensure that the eligibility checking op completes before insertion operation?
I'm looking for solutions that can be used in a ratpack+java application
Upvotes: 0
Views: 245