Я использую Spring Boot и Webflux.
В моем коде я пытаюсь вернуть Flux, но получаю следующую ошибку от intellij, и код отмечен красным:
no instance(s) of type variable(s) R exists so that Flux<UUID> conforms to Mono<>
My code:
public Flux<UUID> deleteCCProtections(Mono<ProtectionSetRequest> protectionSetRequest) {
return protectionSetRequest.flatMap(
request ->
protectionSetRepository
.findByProtectionSetIdIn(request.getProtectionSetIds())
.collectList()
.flatMap(
protectionSet -> //this line is marked red in Intellij
deleteCCProtectionset(protectionSet, request.getDeleteBackups()))); //this line is marked red in Intellij
}
private Flux<UUID> deleteCCProtectionset(
List<ProtectionSet> protectionSets, boolean deleteRecoveryPoints) {
return Flux.fromIterable(protectionSets)
.flatMap(
protectionSet ->
protectorRepository
.findByProtectionId(protectionSet.getProtectionId())
.flatMap(
protector ->
Mono.zip(
protectBatchService.delete(protector),
protectionSetRepository.delete(protectionSet))
.flatMap(
tuple ->
protectionService.sendUnprotectCommand(
tuple.getT1()))
.doOnNext(subscriptionResourceService::cancelSubscriptionResources)
//
// .doOnNext(agentDataServiceApi::setProtectedResources) //void
.doOnNext(schedulerService::deleteProtection))); //void
}
Что я делаю не так?
UPDATE
Когда я удаляю Mono из параметров deleteCCProtections (Mono protectionSetRequest мой код компилирует - почему ??? Я получаю Mono от контроллера к сервису ...
Рабочий код, но без Mono
public Flux<UUID> deleteCCProtections(ProtectionSetRequest protectionSetRequest) {
return protectionSetRepository
.findByProtectionSetIdIn(protectionSetRequest.getProtectionSetIds())
.collectList()
.flatMapMany(
protectionSet -> //this line is marked red in Intellij
deleteCCProtectionset(protectionSet, request.getDeleteBackups()))); //this line is marked red in Intellij
}
private Flux<UUID> deleteCCProtectionset(
List<ProtectionSet> protectionSets, boolean deleteRecoveryPoints) {
return Flux.fromIterable(protectionSets)
.flatMap(
protectionSet ->
protectorRepository
.findByProtectionId(protectionSet.getProtectionId())
.flatMap(
protector ->
Mono.zip(
protectBatchService.delete(protector),
protectionSetRepository.delete(protectionSet))
.flatMap(
tuple ->
protectionService.sendUnprotectCommand(
tuple.getT1()))
.doOnNext(subscriptionResourceService::cancelSubscriptionResources)
//
// .doOnNext(agentDataServiceApi::setProtectedResources) //void
.doOnNext(schedulerService::deleteProtection))); //void
}