Reputation: 65
I'm getting this error in the below method in line "return Mono.justOrEmpty(routeLink.getComplianceIds())"
private Flux<BOLCompliance> getComplienceRouteLink(BOLRouteLink routeLink, BillOfLadingResponse bol) {
return Mono.justOrEmpty(routeLink.getComplianceIds())
.flatMapMany(Flux::fromIterable)
.flatMap(id -> complianceCaller.getComplianceById(id))
.map(compliance -> createComplianceResponse(compliance, bol));
}
routeLink.getComplianceIds() returns a List of type String, createComplianceResponse returns a Mono of type BOLCompliance and complianceCaller.getComplianceById(id)) returns a Mono of type Compliance
public Mono<Compliance> getComplianceById(String complianceID);
private Mono<BOLCompliance> createComplianceResponse(Compliance compliance, BillOfLadingResponse bol);
Upvotes: 0
Views: 705
Reputation: 1799
Your
.map(compliance -> createComplianceResponse(compliance, bol));
Should be
.flatMap(compliance -> createComplianceResponse(compliance, bol));
As your return type is Mono<BOLCompliance>
for createComplianceResponse
, and you want the BOLCompliance
to go further down the stream, not the Mono
objects. In your example the resulting Flux is Flux<Mono<BOLCompliance>>
.
Upvotes: 2