Created
November 24, 2022 12:13
-
-
Save frank9615/040913af73b6f9abe542b4025f32716d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@QuarkusMain | |
@Slf4j | |
public class ExampleResource { | |
public static void main(String[] args) throws IOException { | |
Multi.createFrom().iterable(Arrays.asList(1,2,3,4)) | |
.onItem() | |
.call(integer -> { | |
System.out.println(integer); | |
if(integer.equals(2)){ | |
//Faccio fallire volontariamente il multi perchè | |
// è una condizione di uscita | |
return Uni.createFrom().failure(new Throwable("Condizione Complatata")); | |
} | |
return Uni.createFrom().voidItem(); | |
}) | |
.onFailure().recoverWithCompletion() | |
.collect().asList() | |
.onItem().invoke(integers -> System.out.println(integers)) | |
.replaceWithVoid().await().indefinitely(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment