ATask 多用途异步任务执行框架-更新 V1.1.0

栏目: 软件资讯 · 发布时间: 5年前

内容简介:更新V1.1.0,增加监控功能,可实时监控任务运行情况。 使用方法: 第一种方式: 注册一个 ServletRegistrationBean 类 public ServletRegistrationBean<StatViewServlet> druidStatViewServlet() { TaskEn...

更新V1.1.0,增加监控功能,可实时监控任务运行情况。

使用方法:

第一种方式:

注册一个 ServletRegistrationBean 类

public ServletRegistrationBean<StatViewServlet> druidStatViewServlet() {
    TaskEngine engine = new TaskEngine.Builder()
                    .build();
    engine.prepareGroup("test");
    // 设置 TaskEngine
    TaskStatService.setTaskEngine(engine);
    // 注册 StatViewServlet,并为其设置路径
    ServletRegistrationBean<StatViewServlet> registrationBean =
            new ServletRegistrationBean<>(new StatViewServlet(), "/atask/*");
    registrationBean.addInitParameter("username", "root");// 设置登录用户名
    registrationBean.addInitParameter("password", "1234");// 设置登录密码
    return registrationBean;
}

第二种方式:

首先新建一个 TaskEngine, 然后将其设置到 TaskStatService

// 也可以采用其他方式
static TaskEngine engine;
static {
    engine = new TaskEngine.Builder()
            .build();
    TaskStatService.setTaskEngine(engine);
}

然后新建一个 Servlet 类,并添加 @WebServlet 注解

@WebServlet(
    urlPatterns = "/atask/*",
    initParams = {
            @WebInitParam(name = "username", value = "admin"),
            @WebInitParam(name = "password", value = "123456"),
    }
)
public class ATaskStatServlet extends StatViewServlet {
    
}

不要忘了在启动类上添加 @ServletComponentScan 注解

@SpringBootApplication
@ServletComponentScan
public class DemoApplication {
}

监控页面:

ATask 多用途异步任务执行框架-更新 V1.1.0


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Learning PHP, MySQL, and JavaScript

Learning PHP, MySQL, and JavaScript

Robin Nixon / O'Reilly Media / 2009-7-21 / USD 39.99

Learn how to create responsive, data-driven websites with PHP, MySQL, and JavaScript - whether or not you know how to program. This simple, streamlined guide explains how the powerful combination of P......一起来看看 《Learning PHP, MySQL, and JavaScript》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具