我正在尝试为配置了spring boot的spring batch/spring cloud任务应用程序配置XA /分布式事务.
我添加了以下依赖项,希望依赖spring boot auto配置:
compile("org.springframework.boot:spring-boot-starter-jta-atomikos")
Run Code Online (Sandbox Code Playgroud)
但是,以下两个类会导致配置两个事务管理器:
org.springframework.cloud.task.configuration.SimpleTaskConfiguration
org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration
请参阅以下消息:
2016-07-18 21:46:19.952 INFO 18995 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.task.configuration.SimpleTaskConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.cloud.task.configuration.SimpleTaskConfiguration]
Run Code Online (Sandbox Code Playgroud)
然后因为配置了PlatformTransactionManager命名transactionManager,我的atomikos自动配置没有被选中:
AtomikosJtaConfiguration did …Run Code Online (Sandbox Code Playgroud) distributed-transactions spring-batch spring-boot spring-cloud-task
我想在cloudfoundry上运行spring应用程序作为使用java buildpack的一次性任务.
请注意,我的应用程序不是Web应用程序,而是使用spring cloud任务的spring批处理应用程序.
这是我的清单:
---
buildpack: https://github.com/cloudfoundry/java-buildpack.git
memory: 1024M
env:
APPLICATION_URL: http://bignibou-server.cfapps.io/
APPLICATION_MAIL_NO_REPLY_ADDRESS: balteo@bignibou-server.cfapps.io
SPRING_PROFILES_ACTIVE: cloud
applications:
- name: bignibou-server
path: bignibou-server/build/libs/bignibou-server.jar
env:
APPLICATION_GOOGLE_API_KEY: ******************
- name: bignibou-batch
path: bignibou-batch/build/libs/bignibou-batch.jar
no-hostname: true
no-route: true
command: null
health-check-type: none
env:
JAVA_OPTS: -Dspring.batch.job.names=messagesDigestMailingJob
Run Code Online (Sandbox Code Playgroud)
每当我推送应用程序时,它都被检测为工作者应用程序:
App bignibou-batch is a worker, skipping route creation
Run Code Online (Sandbox Code Playgroud)
这就是我想要的.
但后来它尝试将批处理作为Web应用程序启动(仍在部署应用程序时)...请参阅:
2017-03-24T22:33:50.828+01:00 [CELL/0] [OUT] Destroying container
2017-03-24T22:33:50.854+01:00 [API/3] [OUT] Process has crashed with type: "web"
2017-03-24T22:33:50.873+01:00 [API/3] [OUT] App instance exited with guid befc8bf2-d338-45e1-90b9-430ff3b09a3f payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", …Run Code Online (Sandbox Code Playgroud) cloud-foundry pivotal-web-services pivotal-cloud-foundry spring-cloud-task
我想使用spring-complex-task来执行我的应用程序,并且我已经构建了可以完美执行的复杂spring-batch Flow Jobs。
您能解释一下弹簧批处理流程作业与弹簧编写任务之间的区别吗?其中哪个最好?
我已经创建了带有春季云任务的春季启动应用程序,该任务应该执行一些命令(任务)。每个任务/命令都是短期任务,所有任务都从命令行开始,执行一些简短的ETL作业并完成执行。
有一个包含所有命令/任务的spring boot jar。每个任务都是CommandLineRunner,我想根据命令行中的参数来决定执行哪些任务(一个或多个)。最佳做法是什么?我不喜欢有肮脏的代码问“如果不是”或类似的东西。
我正在将 Spring Batch 与 Spring 云任务结合使用。我的工作中有以下配置:
@Bean
public Job jobDemo(
@Value("${jobname}")String jobName,
JobBuilderFactory jobBuilderFactory,
JobCompletionNotificationListener listener
) {
return jobBuilderFactory.get(jobName)
.incrementer(new RunIdIncrementer())
.preventRestart()
.listener(listener)
.flow(stepA())
.end()
.build();
}
Run Code Online (Sandbox Code Playgroud)
我不想在作业中使用重新启动功能,这就是我将.preventRestart(). 我想在每次任务运行时启动一个新作业,即即使上次作业失败或停止或发生任何其他情况,也要运行作业的新实例。但我收到以下错误:
org.springframework.batch.core.repository.JobRestartException: JobInstance already exists and is not restartable
Run Code Online (Sandbox Code Playgroud)
仅在作业未成功完成的情况下才会发生这种情况。关于解决方案有什么想法吗?
我浏览了Introducing Spring Cloud Task,但对于以下问题尚不清楚。
我正在使用 Spring Batch
当我们已经有了 Spring Batch 提供的元数据时,Spring Cloud Task有什么用?
我们计划使用 Spring Cloud Data Flow 来监控 Spring Batch。所有批处理作业都可以作为任务导入 SCDF 并可以在那里安排,但看不到对 MongoDB 的支持。希望 MySQL 运行良好。
Spring Cloud Task 和 Spring Batch 有什么区别?
我们计划淘汰现有的旧Java批处理应用程序,并使用最新的可用批处理框架重新创建它.鉴于我们有大量的批处理作业需要现代化,我们正在寻找一个允许我们的框架或架构
spring spring-batch spring-boot spring-cloud spring-cloud-task
我知道可以安排云任务,也可以使用要执行的流进行配置。作为开发人员,我想使用 rest-api 执行我的 spring 云任务,以便我可以按需执行任务。基本上我有一个工作流程管理系统,我们正在使用 control-m 代理。所以现在一些作业将由 control-m 执行,一些任务将部署在 spring 云数据流服务器上。现在,当一项工作完成时,必须执行云上的另一项工作。因此,为此我需要能够调用 rest api 并按需执行云任务。我确信此功能必须存在,但我找不到文档示例。有人可以帮帮我吗。提前致谢。
我们正在与两个不同的团队开发两个项目。然而,这两个项目有一些共同点,例如,有共同的实体和存储库使用案例。如何在不使用代码复用的情况下管理两个项目中的单个实体/存储库?
注意:第一个项目是 spring-batch/spring cloud task 第二个项目是微服务项目
谢谢...
architecture spring-batch spring-boot microservices spring-cloud-task