Skip to content

Save Object along the reactive pipeline. #812

Answered by cescoffier
guy1699 asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know much about the subscription handling of Spring Boot, but with Quarkus (and RESTEasy Reactive) you can do something like:

    AtomicInteger counter = new AtomicInteger();

    @GET
    @Path("/hey")
    public Uni<String> asyncGreeting(@RestQuery String name) {
        return Uni.createFrom().context(c -> {
            c.put("user.name", name);
            c.put("count", counter.incrementAndGet());
            return asyncGreeting();
        });
    }

    private Uni<String> asyncGreeting() {
        return Uni.createFrom()
                .context(c -> Uni.createFrom().item(() -> "Hey " + c.get("user.name") + " (" + c.get("count") + ")")
                .runSubscriptionOn(In…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

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