Skip to content

Execute fire and forget for long running process #1209

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

You must be logged in to vote

In general, when I need to do such kind of things, I use the following pattern:

public Uni<String> longRunningProcess() { ... }

// ...

var csJustInCaseINeedToCheck = longRunningProcess()
     .runSubscriptionOn(Infrastructure.getDefaultWorkerPool() // If it's blocking, make sure it does not block the current thread
    .subscribeAsCompletionStage(); // Trigger the operation and return a completion stage so I can check if it completed or failed

Replies: 1 comment 1 reply

Comment options

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

Answer selected by DevEnol
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