Spring Batch 应用程序与 Spring Batch 管理集成
我开发了一个 Spring Batch 应用程序,该应用程序使用批处理/shell 脚本部署为可执行 jar。效果很好。
最近我读到了有关 Spring Batch 管理应用程序发布的信息。根据他们的文档,他们说你必须指向 job-context.xml,这将允许管理 Spring Batch 应用程序从管理应用程序启动、重新启动和停止。现在我的问题是我是否必须将 job-context.xml 保留在 jar 之外,或者确切的步骤是什么,我对此配置感到困惑。 对此的任何见解都非常有用,顺便说一句,我正在使用 spring Batch 2.1。
谢谢
I developed one spring batch application which is deployed as executable jar using batch/shell script. It works fine.
Now recently I read about spring batch admin application release. As per their doc, they say you have to point to job-context.xml and that will allow to manage spring batch app to be started,restarted and stopped from admin app. Now my question is do I have to keep my job-context.xml outside the jar or what are the exact steps, i am confused about this configuration.
Any insight on this is very useful and by the way I am using spring batch 2.1.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Spring Batch 管理应用程序是一个很好的参考实现,并且是高度可定制的。所有接口实现都可以通过 Spring DI 使用您自己的类进行替换。 UI 也是模板驱动的(我认为是 FreeMarker),因此可以自定义以显示相关信息、更改皮肤等。
我有像您一样的类似需求 - 需要在构建为 jar 的应用程序中包含管理功能。我不太喜欢必须将作业打包为 .war 文件这一事实。相反,我从 Spring Batch Admin 源中提取了相关配置,并创建了一个在文件系统之外工作并在嵌入式 Jetty 服务器上运行的部署。
请参阅此处的屏幕截图:https://github.com/regunathb/Trooper/ wiki/Trooper-Batch-Web-Console
源代码、配置等可在此处获取:https://github.com/regunathb/Trooper/tree/master/batch-core 。该项目实际上创建了一个 .jar 而不是 .war
The Spring Batch admin application is a good reference implementation and is highly customizable. All interface implementations may be replaced via Spring DI using your own classes. UI is also template driven(FreeMarker I think) and therefore may be customized to display relevant information, change skin etc.
I had a similar need like yours - need admin functionality included in an app built as jar. I did not quite like the fact that I had to package my jobs as a .war file. Instead I extracted relevant configurations from Spring Batch Admin source and created a deployment that works off file system and runs on embedded Jetty server.
See screen shots here : https://github.com/regunathb/Trooper/wiki/Trooper-Batch-Web-Console
Source, configurations etc are available here : https://github.com/regunathb/Trooper/tree/master/batch-core . This project actually creates a .jar and not .war
如果您的应用程序具有自定义类并且部署为可运行的 jar 并且不包含在 Spring Batch 管理中,则您无法启动作业。您只能在数据库中查看作业的状态并“杀死”它们的状态。
如果您查看 http://static.springsource.org/spring-batch -admin/reference/reference.xhtml 在配置上传部分的末尾,它指出
如果您的作业是严格可配置的作业,就像您仅使用 XML 来定义它们一样,不需要执行任何自定义项读取器/处理器/编写器或其他自定义类,那么您可以上传作业 XML,并且可以从管理站点内运行。如果您有自定义类,那么根据我的经验,您必须在 Web 应用程序中部署 Spring Batch 应用程序,然后上传包含您想要单独运行的作业的 XML。
我个人只是使用管理工具来查看工作状态并通过一些自定义页面为我提供统计数据。我让调度程序来运行作业,并且我不希望那些有权访问管理站点的人在他们对此一无所知的情况下启动作业。基本上,用它给用户一种温暖的模糊感,而不让他们把它搞砸。 (让用户找到您没有考虑到的边缘情况)
If your application has custom classes and is deployed as a runnable jar and not contained within the spring batch admin, you cannot start jobs. You can only view the status of jobs and "kill" their status in the database.
If you look at http://static.springsource.org/spring-batch-admin/reference/reference.xhtml at the end of the Configuration Upload section it states
If your jobs are strictly configurable jobs, as-in you use only XML to define them and do not need to do any customized item readers/processors/writers or other custom classes, then you can upload the job XML and it will be runnable from within the admin site. If you have custom classes then, from my experience, you will have to have the spring batch application deployed within your web application and then upload an XML that contains the jobs you want to run separately.
I personally just used the Admin tool to view job status and provide me with statistics through some custom pages. I left the scheduler to run the jobs and I didn't want those with access to the admin site to kick off a job when they knew nothing about it. Basically, used it to give the users a warm fuzzy without allowing them to muck it up. (leave it to a user to find an edge case you didn't account for)