79079653

Date: 2024-10-11 20:36:32
Score: 2
Natty:
Report link

I'm not sure to have understood fully the question.

current implementation is giving me two instance of CustomerDashboardDTO and that too after 10 sec but expected is one object of CustomerDashboardDTO when we receive profile and bene and same object will get update as soon we get accounts.

If what you're looking for is to combine the three sources and wait for all of them before emitting, why not zipping the three sources?

public Mono<CustomerDashboardDTO> getCustomerDashboard() {

        Mono<CustomerProfile> customerProfile = findCustomerProfile();
        Mono<List<BeneficiaryDetails>> beneficiaries = findBeneficiaryDetails();
        Mono<Account> account = Mono.delay(Duration.ofSeconds(10))
            .flatMap(delay -> findAccount());

        return Mono.zip(customerProfile, account, beneficiaries)
            .map(t -> new CustomerDashboardDTO(t.getT1(), t.getT2(), t.getT3()));
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: gdevxy