diff --git a/README.md b/README.md index 516b307f9..52116160b 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ disjob # 主项目① - [管理后台—disjob-admin](disjob-admin/pom.xml) - [范例项目—disjob-samples](disjob-samples/pom.xml) -2. 启动以下各应用组成分布式调度集群 +2. 启动以下各应用(执行java main方法)组成分布式调度集群 > 已配置不同的端口可同时启动。可以在开发工具中运行Java类,也可通过`java -jar`命令运行构建好的jar包。 diff --git a/disjob-admin/pom.xml b/disjob-admin/pom.xml index 0914648e9..fb3b45990 100644 --- a/disjob-admin/pom.xml +++ b/disjob-admin/pom.xml @@ -42,7 +42,7 @@ 2.3.3 1.4.7 1.2.83 - 6.4.11 + 6.4.13 2.15.1 5.2.5 2.3 diff --git a/disjob-core/src/main/java/cn/ponfee/disjob/core/handle/impl/GroovyJobHandler.java b/disjob-core/src/main/java/cn/ponfee/disjob/core/handle/impl/GroovyJobHandler.java index b4e2a8d3a..7fe7fa011 100644 --- a/disjob-core/src/main/java/cn/ponfee/disjob/core/handle/impl/GroovyJobHandler.java +++ b/disjob-core/src/main/java/cn/ponfee/disjob/core/handle/impl/GroovyJobHandler.java @@ -35,20 +35,24 @@ * import java.util.* * def uuid = UUID.randomUUID().toString() * savepoint.save(new Date().toString() + ": " + uuid) - * return "execute at: " + new Date() + ", " + jobHandler.toString() + * return "taskId: " + executingTask.getTaskId() + ", execute at: " + new Date() + ", " + jobHandler.toString() * } * * @author Ponfee */ public class GroovyJobHandler extends JobHandler { + public static final String JOB_HANDLER = "jobHandler"; + public static final String EXECUTING_TASK = "executingTask"; + public static final String SAVEPOINT = "savepoint"; + @Override public ExecuteResult execute(ExecutingTask executingTask, Savepoint savepoint) throws Exception { String scriptText = executingTask.getTaskParam(); Map params = ImmutableMap.of( - "jobHandler", this, - "executingTask", executingTask, - "savepoint", savepoint + JOB_HANDLER, this, + EXECUTING_TASK, executingTask, + SAVEPOINT, savepoint ); Object result = GroovyUtils.Evaluator.SCRIPT.eval(scriptText, params); diff --git a/disjob-registry/disjob-registry-nacos/pom.xml b/disjob-registry/disjob-registry-nacos/pom.xml index bfdc1b78f..6d2dabf1d 100644 --- a/disjob-registry/disjob-registry-nacos/pom.xml +++ b/disjob-registry/disjob-registry-nacos/pom.xml @@ -25,7 +25,7 @@ com.alibaba.nacos nacos-client - 2.3.0 + 2.3.1 diff --git a/disjob-samples/disjob-samples-frameless-worker/pom.xml b/disjob-samples/disjob-samples-frameless-worker/pom.xml index 3a236b346..d25269d59 100644 --- a/disjob-samples/disjob-samples-frameless-worker/pom.xml +++ b/disjob-samples/disjob-samples-frameless-worker/pom.xml @@ -40,7 +40,7 @@ io.vertx vertx-web - 4.4.5 + 4.5.4 io.netty diff --git a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java index 50eafca8d..e367d9ed1 100644 --- a/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java +++ b/disjob-samples/disjob-samples-frameless-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerFramelessMain.java @@ -67,7 +67,7 @@ public class WorkerFramelessMain { static { - // for log4j log file dir + // for log4j2 log file name System.setProperty("app.name", "frameless-worker"); JobHandlerParser.init(); } diff --git a/disjob-samples/disjob-samples-springboot-merged/src/main/java/cn/ponfee/disjob/samples/merged/MergedApplication.java b/disjob-samples/disjob-samples-springboot-merged/src/main/java/cn/ponfee/disjob/samples/merged/MergedApplication.java index 31f326034..f2b99197a 100644 --- a/disjob-samples/disjob-samples-springboot-merged/src/main/java/cn/ponfee/disjob/samples/merged/MergedApplication.java +++ b/disjob-samples/disjob-samples-springboot-merged/src/main/java/cn/ponfee/disjob/samples/merged/MergedApplication.java @@ -44,7 +44,7 @@ public class MergedApplication extends AbstractSamplesApplication { static { - // for log4j log file dir + // for log4j2 log file name System.setProperty("app.name", "springboot-merged"); } diff --git a/disjob-samples/disjob-samples-springboot-supervisor/src/main/java/cn/ponfee/disjob/samples/supervisor/SupervisorApplication.java b/disjob-samples/disjob-samples-springboot-supervisor/src/main/java/cn/ponfee/disjob/samples/supervisor/SupervisorApplication.java index 7553a0210..6c6e65f6c 100644 --- a/disjob-samples/disjob-samples-springboot-supervisor/src/main/java/cn/ponfee/disjob/samples/supervisor/SupervisorApplication.java +++ b/disjob-samples/disjob-samples-springboot-supervisor/src/main/java/cn/ponfee/disjob/samples/supervisor/SupervisorApplication.java @@ -40,7 +40,7 @@ public class SupervisorApplication extends AbstractSamplesApplication { static { - // for log4j log file dir + // for log4j2 log file name System.setProperty("app.name", "springboot-supervisor"); } diff --git a/disjob-samples/disjob-samples-springboot-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerApplication.java b/disjob-samples/disjob-samples-springboot-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerApplication.java index 362e9e20a..6502340cc 100644 --- a/disjob-samples/disjob-samples-springboot-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerApplication.java +++ b/disjob-samples/disjob-samples-springboot-worker/src/main/java/cn/ponfee/disjob/samples/worker/WorkerApplication.java @@ -33,7 +33,7 @@ public class WorkerApplication extends AbstractSamplesApplication { static { - // for log4j log file dir + // for log4j2 log file name System.setProperty("app.name", "springboot-worker"); } diff --git a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/AbstractDataSourceConfig.java.bak b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/AbstractDataSourceConfig.java.bak index a45d8e989..436dcee22 100644 --- a/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/AbstractDataSourceConfig.java.bak +++ b/disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/base/AbstractDataSourceConfig.java.bak @@ -114,45 +114,6 @@ public abstract class AbstractDataSourceConfig implements ApplicationContextAwar this.environment = environment; } - /** - * 使用该方式时,基于注解方式的事务不生效 - */ - @Override - public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory listableBeanFactory) throws BeansException { - // -------------------------data source - DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) listableBeanFactory; - DataSource dataSource = DataSourceBuilder.create() - //.type(com.zaxxer.hikari.HikariDataSource.class) - .build(); - Binder binder = Binder.get(environment); - binder.bind(databaseName + ".datasource", Bindable.ofInstance(dataSource)); - beanFactory.registerSingleton(databaseName + DATA_SOURCE_NAME_SUFFIX, dataSource); - - // -------------------------register to spring as singleton bean - SqlSessionFactory sqlSessionFactory; - try { - sqlSessionFactory = createSqlSessionFactory(dataSource); - } catch (Exception e) { - throw new BeanInstantiationException(SqlSessionFactory.class, "Create mybatis SqlSessionFactory error.", e); - } - beanFactory.registerSingleton(databaseName + SQL_SESSION_FACTORY_NAME_SUFFIX, sqlSessionFactory); - beanFactory.registerSingleton(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX, new SqlSessionTemplate(sqlSessionFactory)); - beanFactory.registerSingleton(databaseName + JDBC_TEMPLATE_NAME_SUFFIX, new JdbcTemplate(dataSource)); - PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource); - beanFactory.registerSingleton(databaseName + TX_MANAGER_NAME_SUFFIX, transactionManager); - beanFactory.registerSingleton(databaseName + TX_TEMPLATE_NAME_SUFFIX, new TransactionTemplate(transactionManager)); - - // -------------------------mybatis mapper scanner - MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); - mapperScannerConfigurer.setBasePackage(this.getClass().getPackage().getName() + ".mapper"); - mapperScannerConfigurer.setSqlSessionTemplateBeanName(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX); - mapperScannerConfigurer.setBeanName(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX); - mapperScannerConfigurer.postProcessBeanDefinitionRegistry(beanFactory); - mapperScannerConfigurer.setProcessPropertyPlaceHolders(true); - mapperScannerConfigurer.setApplicationContext(applicationContext); - beanFactory.registerSingleton(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX, mapperScannerConfigurer); - } - /** * 使用该方式时,基于注解方式的事务不生效 * 要加`@EnableTransactionManagement`才能使事务生效 @@ -220,6 +181,45 @@ public abstract class AbstractDataSourceConfig implements ApplicationContextAwar //registry.registerBeanDefinition(ProxyTransactionManagementConfiguration.class.getName(), new RootBeanDefinition(ProxyTransactionManagementConfiguration.class)); } + /** + * 使用该方式时,基于注解方式的事务不生效 + */ + @Override + public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory listableBeanFactory) throws BeansException { + // -------------------------data source + DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) listableBeanFactory; + DataSource dataSource = DataSourceBuilder.create() + //.type(com.zaxxer.hikari.HikariDataSource.class) + .build(); + Binder binder = Binder.get(environment); + binder.bind(databaseName + ".datasource", Bindable.ofInstance(dataSource)); + beanFactory.registerSingleton(databaseName + DATA_SOURCE_NAME_SUFFIX, dataSource); + + // -------------------------register to spring as singleton bean + SqlSessionFactory sqlSessionFactory; + try { + sqlSessionFactory = createSqlSessionFactory(dataSource); + } catch (Exception e) { + throw new BeanInstantiationException(SqlSessionFactory.class, "Create mybatis SqlSessionFactory error.", e); + } + beanFactory.registerSingleton(databaseName + SQL_SESSION_FACTORY_NAME_SUFFIX, sqlSessionFactory); + beanFactory.registerSingleton(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX, new SqlSessionTemplate(sqlSessionFactory)); + beanFactory.registerSingleton(databaseName + JDBC_TEMPLATE_NAME_SUFFIX, new JdbcTemplate(dataSource)); + PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource); + beanFactory.registerSingleton(databaseName + TX_MANAGER_NAME_SUFFIX, transactionManager); + beanFactory.registerSingleton(databaseName + TX_TEMPLATE_NAME_SUFFIX, new TransactionTemplate(transactionManager)); + + // -------------------------mybatis mapper scanner + MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); + mapperScannerConfigurer.setBasePackage(this.getClass().getPackage().getName() + ".mapper"); + mapperScannerConfigurer.setSqlSessionTemplateBeanName(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX); + mapperScannerConfigurer.setBeanName(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX); + mapperScannerConfigurer.postProcessBeanDefinitionRegistry(beanFactory); + mapperScannerConfigurer.setProcessPropertyPlaceHolders(true); + mapperScannerConfigurer.setApplicationContext(applicationContext); + beanFactory.registerSingleton(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX, mapperScannerConfigurer); + } + private SqlSessionFactory createSqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); factoryBean.setDataSource(dataSource); diff --git a/pom.xml b/pom.xml index 59fb4223f..5d9a6b219 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ 2.5.3 1.4 0.18.1 - 1.19.5 + 1.19.7 3.2.0