#134 Parallel Data Aggregation from Microservices
Implement an API composition method whose theoretical execution time approaches 300ms.
The method calls three external microservices. Their calls and average response times are shown below:
List<GroupDTO> GroupFeignClient.search(GroupsSearchCriteriaDTO searchDTO); // 200-350ms
UserDTO UserFeignClient.findById(String userId); // 50-160ms
ScoringDTO ScoringFeignClient.findByUserId(String userId); // 100-250ms
@Service
class SuperUserServiceImpl{
final GroupFeignClient groupClient;
final UserFeignClient userClient;
ScoringFeignClient scoringClient;
SuperUserDTO findById(String userId){
searchDTO = GroupsSearchCriteriaDTO.builder().userId(userId).build();
// implement an API composition method whose theoretical time approaches 300ms
return new SuperUserDTO();
}
}
class SuperUserDTO {
String id;
String name;
String lastname;
Float score;
List<GroupDTO> groups;
}
class UserDTO {
String id;
String name;
String lastname;
String phone;
String email;
}
class GroupDTO {
String id;
String code;
String label;
String division;
String description;
String email;
}
class ScoringDTO {
String userId;
Float score;
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor