- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Quarkus 有一个 https://quarkus.io/guides/scheduler来安排任务。但是,我想使用 ScheduledExecutorService
.这在夸克中是允许的吗?例如,在wildfly 中有ManagedScheduledExecutorService
必须使用,因为服务器正在管理线程,不允许用户管理线程。这对夸克也有效吗?
最佳答案
这是一个 SimpleSheduler 类(class)
包裹:package io.quarkus.scheduler.runtime;
https://github.com/quarkusio/quarkus/blob/main/extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SimpleScheduler.java
为了开发调度程序扩展,他们使用了 ScheduledExecutorService。
这是一个使用 的调度任务ScheduledExecutorService ,
import javax.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ApplicationScoped
public class ScheduledExecutorRunnable {
List<String> list =
new ArrayList<String>();
public List<String> get() {
sheduleTask();
return list;
}
void sheduleTask() {
ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
Runnable task2 = () -> list.add("Running task2...");
task1();
ses.schedule(task2, 10, TimeUnit.SECONDS);
task3();
ses.shutdown();
}
void task1() {
list.add("Running task1...");
}
void task3() {
list.add("Running task3...");
}
}
演示
import com.knf.dev.Resource.ScheduledExecutorService.ScheduledExecutorRunnable;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("/verify")
public class EndPoint {
@Inject
ScheduledExecutorRunnable scheduledExecutorRunnable;
@GET
@Path("/sheduler")
@Produces(MediaType.APPLICATION_JSON)
public List<String> sheduler() {
return scheduledExecutorRunnable.get();
}
}
命中端点:
http://localhost:8080/verify/sheduler
关于quarkus 和 ScheduledExecutorService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66748191/
我已经使用 将资源添加到类路径中 -H:IncludeResources=.*/kubernetes_auth.crt$ -H:Log=registerResource:verbose 当我构建图像时
我正在阅读 Quarkus documentation about configuration ,这引起了我的注意: Quarkus does much of its configuration an
我有一系列简单的链式操作,它们使用在 Quarkus 服务中运行的 Panache 存储库检索和保存一些数据。这些操作并行化的地方是 ContextNotActiveException被抛出。在删除并
我最近开始在我的 Quarkus 网络应用程序中使用 testcontantainers 进行单元/集成测试数据库操作。它工作正常,除了我想不出在 quarkus.datasource.url 应用程
我想更改 Quarkus 应用程序的日志记录级别。 如何从配置文件或在运行时执行此操作? 最佳答案 控制根日志记录级别的属性是 quarkus.log.level (默认为 INFO )。 此属性可以
我正在寻找一种方法来在运行时更改 Quarkus 应用程序 (JVM) 的一个或多个类/包的日志级别。是否有我可以用来以编程方式更改级别的 API,例如通过公开 REST API 还是已经存在其他解决
我已经使用 Quarkus 开发模式 ( mvn quarkus:dev ) 启动了我的应用程序,我希望能够调试它。 怎么能这样? 最佳答案 只需使用 mvn quarkus:dev 启动 Quark
在我当前的项目中,我们将用户登录信息存储在 MongoDB 集合中。我们希望实现一种身份验证机制,根据存储在所述 MongoDB 中的信息检查请求中的凭据。有一个教程可以做到这一点with JPA +
我的 application.properties 文件中有一些配置: ... quarkus.datasource.url=jdbc:postgresql://...:5432/.... quark
在夸库斯 Application Configuration Guide它提到了如何使用配置文件配置应用程序(例如%dev.quarkus.http.port=8181)。 但是有没有办法访问配置文件
我希望我的 Quarkus 应用程序在默认端口以外的端口上运行。我怎样才能做到这一点? 最佳答案 要使用的 Quarkus 配置属性是 quarkus.http.port(默认值为 8080)。如果在
Quarkus getting started unittest描述如何模拟注入(inject)的服务。然而,当尝试将此应用于注入(inject)的休息客户端时,这似乎不起作用。 在我的应用程序中,要
我曾尝试在 Quarkus 中添加 logback,但后来发现 Quarkus 不支持 logback。如果我错了,我可以通过示例知道如何在 Quarkus 中配置 logback 吗?提前致谢。 最
在使用 Quarkus Restclient/RESTEasy 进行集成测试时,我们希望在运行时覆盖 url 和端口。这样做的原因是,如果我们并行构建多个模块,我们需要使用随机端口,否则我们会遇到端口
我正在尝试将 JEE 服务迁移到 Quarkus想知道如何在 Quarkus 应用程序中获取线程工厂。只需创建一个像 javaExecutors.defaultThreadFactory();就像在
我正在使用 quarkus 1.2.0。 一般: 客户端浏览器向服务器请求数据。服务器(Quarkus 应用程序)正在从客户端接收 UTC 时间。 (ok) 现在服务器应该将数据库中的数据与客户端浏览
我试图找到一种方法如何在 quarkus DI 中以编程方式创建 bean,但没有成功。在这个框架下可以吗?看来BeanManager尚未实现所需的方法。 最佳答案 首先,我们应该澄清“以编程方式创建
我创建了以下调用类,当调用拦截的方法时,应该调用它: import javax.interceptor.AroundInvoke; import javax.interceptor.Intercept
我正在尝试将多模块 Maven 项目从普通 Java EE 8 转换为 Quarkus,并且 ArcAnnotationProcessor 似乎会抛出有关引用位于不同位置的依赖项的所有注入(injec
我们如何在 Quarkus 中使用 jasypt 加密和解密属性文件中的数据库密码。解密将在加载或启动应用程序时发生。请分享您对此的意见或想法。 @chrisgleissner 非常感谢任何帮助。 应
我是一名优秀的程序员,十分优秀!