简体   繁体   English

Java类包含批处理作业的业务逻辑

[英]Java class contain the business logic of batch job

I have a big xml file that I want to get transferred from c: drive to d: drive at particular time period. 我有一个大的xml文件,希望在特定时间段从c:驱动器传输到d:驱动器。

I want to design a Java class to perform a batch job . 我想设计一个Java类来执行batch job This would means that the java class will act like a batch job and it will pick the xml file from c: drive and will send it to d: drive at particular time.I want the other time setting and file location specifications to be done in xml file and the rest java class would contain the buisness logic. 这意味着java类将像批处理作业一样工作,它将从c:驱动器中选择xml文件,并在特定时间将其发送到d:驱动器中。我希望其他时间设置和文件位置规范在xml文件,其余的Java类将包含商务逻辑。

Please advise how to achieve this , and also please let me know any of frameworks like Spring or Spring Integration, Spring Batch that might provide any help..! 请告知如何实现此目标,并让我知道像Spring或Spring Integration,Spring Batch之类的任何框架,它们可能会提供帮助。

I am more interested in spring batch!! 我对春季批更感兴趣!

I would recommend using your OS scheduler to achieve this. 我建议您使用OS调度程序来实现此目的。 Put your business logic in the Java code any way you want but on windows schedule it with the windows scheduler, on unix use cron. 将您的业务逻辑以任何您想要的方式放入Java代码,但在Windows上使用Windows Scheduler对其进行调度,在UNIX上使用cron。

If you absolutely need Java to be the scheduler as well, look into Quartz . 如果您也绝对需要Java作为调度程序,请查看Quartz

---- Using Windows Scheduler ---- ----使用Windows Scheduler ----

First, create a batch file to kick off your java code: 首先,创建一个批处理文件以启动您的java代码:

myjavarunner.bat: myjavarunner.bat:

java -classpath <myclasspath> com.silly.project.ClassWithMainMethod <arguments>

This is not strictly necessary, but when working with java, it is often much easier. 这不是严格必需的,但是在使用Java时,它通常要容易得多。 Then, create a scheduled task. 然后,创建一个计划任务。 Click the start button -> Control Panel -> Administrative Tools -> Task Scheduler. 单击开始按钮->控制面板->管理工具->任务计划程序。 Click the Action menu -> Create Task. 单击操作菜单->创建任务。 Fill out all the forms and let er rip. 填写所有表格,然后撕开。

一个简单的开始就是使用Timer安排定期作业,并使用TimerTask来实现业务逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM