Search in sources :

Example 1 with XxlJobExecutor

use of com.xxl.job.core.executor.XxlJobExecutor in project xxl-job by xuxueli.

the class JFinalCoreConfig method initXxlJobExecutor.

private void initXxlJobExecutor() {
    // registry jobhandler
    XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
    XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());
    // load executor prop
    Prop xxlJobProp = PropKit.use("xxl-job-executor.properties");
    // init executor
    xxlJobExecutor = new XxlJobExecutor();
    xxlJobExecutor.setAdminAddresses(xxlJobProp.get("xxl.job.admin.addresses"));
    xxlJobExecutor.setAppName(xxlJobProp.get("xxl.job.executor.appname"));
    xxlJobExecutor.setIp(xxlJobProp.get("xxl.job.executor.ip"));
    xxlJobExecutor.setPort(xxlJobProp.getInt("xxl.job.executor.port"));
    xxlJobExecutor.setAccessToken(xxlJobProp.get("xxl.job.accessToken"));
    xxlJobExecutor.setLogPath(xxlJobProp.get("xxl.job.executor.logpath"));
    xxlJobExecutor.setLogRetentionDays(xxlJobProp.getInt("xxl.job.executor.logretentiondays"));
    // start executor
    try {
        xxlJobExecutor.start();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : ShardingJobHandler(com.xuxueli.executor.sample.jfinal.jobhandler.ShardingJobHandler) XxlJobExecutor(com.xxl.job.core.executor.XxlJobExecutor) DemoJobHandler(com.xuxueli.executor.sample.jfinal.jobhandler.DemoJobHandler) Prop(com.jfinal.kit.Prop)

Example 2 with XxlJobExecutor

use of com.xxl.job.core.executor.XxlJobExecutor in project xxl-job by xuxueli.

the class NutzSetup method init.

@Override
public void init(NutConfig cfg) {
    // regist JobHandler
    String[] beanNames = cfg.getIoc().getNamesByType(IJobHandler.class);
    if (beanNames == null || beanNames.length == 0) {
        return;
    }
    for (String beanName : beanNames) {
        IJobHandler jobHandler = cfg.getIoc().get(IJobHandler.class, beanName);
        String name = jobHandler.getClass().getAnnotation(JobHandler.class).value();
        XxlJobExecutor.registJobHandler(name, jobHandler);
    }
    // load executor prop
    PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");
    // init executor
    xxlJobExecutor = new XxlJobExecutor();
    xxlJobExecutor.setAdminAddresses(xxlJobProp.get("xxl.job.admin.addresses"));
    xxlJobExecutor.setAppName(xxlJobProp.get("xxl.job.executor.appname"));
    xxlJobExecutor.setIp(xxlJobProp.get("xxl.job.executor.ip"));
    xxlJobExecutor.setPort(xxlJobProp.getInt("xxl.job.executor.port"));
    xxlJobExecutor.setAccessToken(xxlJobProp.get("xxl.job.accessToken"));
    xxlJobExecutor.setLogPath(xxlJobProp.get("xxl.job.executor.logpath"));
    xxlJobExecutor.setLogRetentionDays(xxlJobProp.getInt("xxl.job.executor.logretentiondays"));
    // start executor
    try {
        xxlJobExecutor.start();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : IJobHandler(com.xxl.job.core.handler.IJobHandler) JobHandler(com.xxl.job.core.handler.annotation.JobHandler) IJobHandler(com.xxl.job.core.handler.IJobHandler) PropertiesProxy(org.nutz.ioc.impl.PropertiesProxy) XxlJobExecutor(com.xxl.job.core.executor.XxlJobExecutor)

Example 3 with XxlJobExecutor

use of com.xxl.job.core.executor.XxlJobExecutor in project xxl-job by xuxueli.

the class XxlJobConfig method xxlJobExecutor.

@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobExecutor xxlJobExecutor() {
    logger.info(">>>>>>>>>>> xxl-job config init.");
    XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
    xxlJobExecutor.setAdminAddresses(adminAddresses);
    xxlJobExecutor.setAppName(appName);
    xxlJobExecutor.setIp(ip);
    xxlJobExecutor.setPort(port);
    xxlJobExecutor.setAccessToken(accessToken);
    xxlJobExecutor.setLogPath(logPath);
    xxlJobExecutor.setLogRetentionDays(logRetentionDays);
    return xxlJobExecutor;
}
Also used : XxlJobExecutor(com.xxl.job.core.executor.XxlJobExecutor) Bean(org.springframework.context.annotation.Bean)

Example 4 with XxlJobExecutor

use of com.xxl.job.core.executor.XxlJobExecutor in project nutzboot by nutzam.

the class XxlJobStarter method xxlJobExecutor.

@IocBean(create = "start", depose = "destroy")
public XxlJobExecutor xxlJobExecutor() {
    log.info(">>>>>>>>>>> xxl-job config init.");
    XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
    // 声明在application.properties
    xxlJobExecutor.setIp(conf.get(PROP_EXECTOR_IP, "0.0.0.0"));
    xxlJobExecutor.setPort(conf.getInt(PROP_EXECTOR_PORT, 8081));
    xxlJobExecutor.setAppName(conf.get(PROP_EXECTOR_NAME, conf.get("nutz.application.name", "xxl-job-executor")));
    xxlJobExecutor.setAdminAddresses(conf.get(PROP_ADMIN_ADDRESSES, "http://127.0.0.1:8080/xxl-job-admin"));
    xxlJobExecutor.setLogPath(conf.get(PROP_EXECTOR_LOGPATH, "/var/log/xxl-job/jobhandler/"));
    xxlJobExecutor.setAccessToken(conf.get(PROP_ACCESSTOKEN, ""));
    return xxlJobExecutor;
}
Also used : XxlJobExecutor(com.xxl.job.core.executor.XxlJobExecutor) IocBean(org.nutz.ioc.loader.annotation.IocBean)

Aggregations

XxlJobExecutor (com.xxl.job.core.executor.XxlJobExecutor)4 Prop (com.jfinal.kit.Prop)1 DemoJobHandler (com.xuxueli.executor.sample.jfinal.jobhandler.DemoJobHandler)1 ShardingJobHandler (com.xuxueli.executor.sample.jfinal.jobhandler.ShardingJobHandler)1 IJobHandler (com.xxl.job.core.handler.IJobHandler)1 JobHandler (com.xxl.job.core.handler.annotation.JobHandler)1 PropertiesProxy (org.nutz.ioc.impl.PropertiesProxy)1 IocBean (org.nutz.ioc.loader.annotation.IocBean)1 Bean (org.springframework.context.annotation.Bean)1