Skip to content

Split async handling to multiple classes/methods #933

Answered by thebe14
thebe14 asked this question in Q&A
Discussion options

You must be logged in to vote

Final version that works great:

public class Test implements ITest {
    private static final Logger LOG = Logger.getLogger(Test.class);
    private SomeRestClient restClient;

    public Uni<Boolean> test() {
        if(null == restClient) {
            LOG.error("No client");
            return Uni.createFrom().failure(new MyException("client"));
        }

        Uni<Boolean> result = Uni.createFrom().nullItem()
            .ifNoItem().after(Duration.ofMillis(100)).failWith(() -> {
                LOG.error("Timeout");
                return new MyException("timeout");
             )}
            .chain(unused -> {
                // Ignore initial dummy placeholder, start the actual …

Replies: 6 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@jponge
Comment options

@thebe14
Comment options

@jponge
Comment options

@thebe14
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@thebe14
Comment options

Comment options

You must be logged in to vote
6 replies
@jponge
Comment options

@jponge
Comment options

@thebe14
Comment options

@jponge
Comment options

@thebe14
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by thebe14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants