Reputation: 437
I want to start a long-running database operation in a new thread. So the persistence context must be available but there is no return value (or the return value is not needed). Usually i do:
@Inject
MyRepository panachRepo;
new Thread(() -> {
panachRepo.cleanupDatabase();
});
how do i achieve this in quarkus?
Upvotes: 1
Views: 1096
Reputation: 4694
@Inject
ManagedExecutor managedExecutor;
Then you can submit a task to it.
managedExecutor.execute(() -> methodToExecute());
Upvotes: 4