[BatchJobCompletionNotificationListener]!!!工作完成了!
[BatchJobCompletionNotificationListener]作业不再以状态[停止]退出状态[exitCode=completed;exitDescription=]运行。
[BatchJobCompletionNotificationListener]步骤[step1]状态[已完成]退出状态[exitCode=已完成;exitDescription=]。
[SimpleJobLauncher]作业:[flowjob:[name=myjob]]已完成,参数如下:[{run.id=62,-spring.config.location=application.yaml}],状态如下:[STOPPING]
我的日志就到此结束了。
我不确定这是否会有什么不同,但我正在使用JdbcPagingItemReader和PagingQueryProvider(基于这个示例)
# mbenhassine @ localhost in /tmp [9:57:11]
$ git clone https://github.com/spring-guides/gs-batch-processing
Cloning into 'gs-batch-processing'...
remote: Enumerating objects: 1121, done.
remote: Total 1121 (delta 0), reused 0 (delta 0), pack-reused 1121
Receiving objects: 100% (1121/1121), 448.58 KiB | 205.00 KiB/s, done.
Resolving deltas: 100% (682/682), done.
# mbenhassine @ localhost in /tmp [9:57:35]
$ cd gs-batch-processing/complete
# mbenhassine @ localhost in /tmp/gs-batch-processing/complete on git:master o [9:57:45]
$ vim pom.xml
# mbenhassine @ localhost in /tmp/gs-batch-processing/complete on git:master x [9:58:16]
$ cat pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-batch-processing</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
# mbenhassine @ localhost in /tmp/gs-batch-processing/complete on git:master x [9:58:22]
$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-batch-processing 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ gs-batch-processing ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ gs-batch-processing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ gs-batch-processing ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /private/tmp/gs-batch-processing/complete/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ gs-batch-processing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /private/tmp/gs-batch-processing/complete/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ gs-batch-processing ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ gs-batch-processing ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ gs-batch-processing ---
[INFO] Building jar: /private/tmp/gs-batch-processing/complete/target/gs-batch-processing-0.1.0.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.2.RELEASE:repackage (repackage) @ gs-batch-processing ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.558 s
[INFO] Finished at: 2019-02-27T09:58:36+01:00
[INFO] Final Memory: 25M/94M
[INFO] ------------------------------------------------------------------------
# mbenhassine @ localhost in /tmp/gs-batch-processing/complete on git:master x [9:58:36]
$ java -jar target/gs-batch-processing-0.1.0.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-02-27 09:58:47.669 INFO 85483 --- [ main] hello.Application : Starting Application v0.1.0 on localhost with PID 85483 (/private/tmp/gs-batch-processing/complete/target/gs-batch-processing-0.1.0.jar started by mbenhassine in /private/tmp/gs-batch-processing/complete)
2019-02-27 09:58:47.672 INFO 85483 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2019-02-27 09:58:48.491 INFO 85483 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-02-27 09:58:48.497 WARN 85483 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation.
2019-02-27 09:58:48.781 INFO 85483 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2019-02-27 09:58:48.785 INFO 85483 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-02-27 09:58:49.137 INFO 85483 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: HSQL
2019-02-27 09:58:49.298 INFO 85483 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2019-02-27 09:58:49.446 INFO 85483 --- [ main] hello.Application : Started Application in 2.117 seconds (JVM running for 2.528)
2019-02-27 09:58:49.448 INFO 85483 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: []
2019-02-27 09:58:49.532 INFO 85483 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=importUserJob]] launched with the following parameters: [{run.id=1}]
2019-02-27 09:58:49.559 INFO 85483 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [step1]
2019-02-27 09:58:49.646 INFO 85483 --- [ main] hello.PersonItemProcessor : Converting (firstName: Jill, lastName: Doe) into (firstName: JILL, lastName: DOE)
2019-02-27 09:58:49.646 INFO 85483 --- [ main] hello.PersonItemProcessor : Converting (firstName: Joe, lastName: Doe) into (firstName: JOE, lastName: DOE)
2019-02-27 09:58:49.646 INFO 85483 --- [ main] hello.PersonItemProcessor : Converting (firstName: Justin, lastName: Doe) into (firstName: JUSTIN, lastName: DOE)
2019-02-27 09:58:49.646 INFO 85483 --- [ main] hello.PersonItemProcessor : Converting (firstName: Jane, lastName: Doe) into (firstName: JANE, lastName: DOE)
2019-02-27 09:58:49.646 INFO 85483 --- [ main] hello.PersonItemProcessor : Converting (firstName: John, lastName: Doe) into (firstName: JOHN, lastName: DOE)
2019-02-27 09:58:49.658 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results
2019-02-27 09:58:49.661 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JILL, lastName: DOE> in the database.
2019-02-27 09:58:49.661 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JOE, lastName: DOE> in the database.
2019-02-27 09:58:49.661 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JUSTIN, lastName: DOE> in the database.
2019-02-27 09:58:49.661 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JANE, lastName: DOE> in the database.
2019-02-27 09:58:49.662 INFO 85483 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JOHN, lastName: DOE> in the database.
2019-02-27 09:58:49.664 INFO 85483 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=importUserJob]] completed with the following parameters: [{run.id=1}] and the following status: [COMPLETED]
2019-02-27 09:58:49.668 INFO 85483 --- [ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2019-02-27 09:58:49.673 INFO 85483 --- [ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
# mbenhassine @ localhost in /tmp/gs-batch-processing/complete on git:master x [9:58:49]
$
我在我的JAVA应用程序中配置了Spring批处理作业,该应用程序在集群中运行。因此,相同的作业被执行两次,这是我不想要的。 所以我想在作业中配置一个步骤,它将检查CREATE_DATE是否在BATCH_JOB_EXECUTION表中存在,并将继续或故障转移。 如何在spring批处理步骤中进行配置?
我已经使用开始我的作业,当我尝试使用另一个请求停止作业时,然后获取exeption: JobExecutionNotrunningException:JobExecution必须正在运行,才能停止 当打印作业状态总是获取但批处理作业正在运行时 它的web应用程序,首先上传一些CSV文件,并使用spring batch启动一些操作,在执行过程中,如果用户需要停止,则从另一个控制器方法来停止请求,并试
我最近使用。我对DB表进行了必要的更改,并对一些与参数API相关的微小代码进行了更改。 现在,当我运行应用程序时,它正在工作,但是如果一个步骤的退出状态为失败,则作业的存在状态设置为完成。这会导致一些问题,因为我们的应用程序代码将其视为成功执行。我通过在中添加一个代码片段来解决这个问题,在这里我检查列表并手动设置作业退出状态,但是Spring批处理框架不应该处理退出状态吗?
当编写器抛出异常时,我希望能够将步骤和作业状态设置为失败。在做了一些调试和检查Spring批处理源代码后,我注意到配置了一个,它认为是一个致命的异常,因此将作业状态设置为FAILED,所以我将代码包装在我的编写器中的一个try-get中,将包装在中,现在作业和步骤状态设置为FAILED,这是我想要的。我不确定这是否是正确的方法,因为我在任何地方都找不到它的文档,的留档也没有提到它。所以,问题是:这
我正在尝试在后台运行作业,允许我根据某种条件或在超时发生后停止它。 我有这两块代码:
我能够通过命令行使用成功地启动springboot-batch作业。