Open Hans-Wu-cn opened 5 months ago
Hi! I am not familiar with Solon, though db-scheduler should be easy to setup in any framework. I have not tried it with virtual threads, but I believe it should work if you send in an ExecutorService
based on virtual threads
Hi! I am not familiar with Solon, though db-scheduler should be easy to setup in any framework. I have not tried it with virtual threads, but I believe it should work if you send in an based on virtual threads
ExecutorService
Before this, I had tried to adapt to console+db scheduler, but I am very unfamiliar with db scheduler and cannot adapt. I have already implemented a custom thread pool for virtual threads in quatrz. which is very simple because many platform threads need to do operations, and virtual threads do not need to do them. They will automatically recycle them
You can create custom executor services with help of the DbSchedulerCustomizer
, see the example below.
@Component
@RequiredArgsConstructor
public class DbSchedulerCustomizer implements com.github.kagkarlsson.scheduler.boot.config.DbSchedulerCustomizer {
private final DbSchedulerProperties dbSchedulerProperties;
@Override
public Optional<ExecutorService> executorService() {
final ThreadFactory threadFactory = Thread.ofVirtual()
.name(Scheduler.THREAD_PREFIX + "-execute-task-", 1)
.factory();
return Optional.of(Executors.newScheduledThreadPool(dbSchedulerProperties.getThreads(), threadFactory));
}
@Override
public Optional<ExecutorService> dueExecutor() {
final ThreadFactory threadFactory = Thread.ofVirtual()
.name(Scheduler.THREAD_PREFIX + "-execute-due-", 1)
.factory();
return Optional.of(Executors.newSingleThreadExecutor(threadFactory));
}
@Override
public Optional<ScheduledExecutorService> housekeeperExecutor() {
final ThreadFactory threadFactory = Thread.ofVirtual()
.name(Scheduler.THREAD_PREFIX + "-housekeeper-", 1)
.factory();
return Optional.of(Executors.newScheduledThreadPool(3, threadFactory));
}
}
Prerequisites
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
Expected Behavior
Hello @kagkarlsson , may I ask if it supports solon and Java21 and virtual threads? This is very important