Mar 5th, 2013, 08:57 PM
front end interface for spring batch jobs
I have an application which is going to load large amount of data from a flat file at specified location to database using spring batch.Currently it is run through command line.
And it will be run with scheduler but by manually event trigger too.
Jobs and steps are fixed.And file location is specified.
But requirement is to make it more user friendly by adding UI to it.
I don't know if Spring admin console is a good idea for the reasons.
- Its not easy to tweak considering time constraints i am in.
- We want simple plain UI .We do'nt want application user to have flexibility to create new jobs etc.
Only purpose of UI : User can trigger the job launch, Or if possible see the progress of job.
If more than one CSVs are placed at that location, all are read. But from UI ,it should not be programmable.
- Creating a JSP with plain button to launch job and then sleep for 'n' hours till job is completed does not seem good to me either.
Since i am totally new to this api and have not come across much examples over internet, someone please suggest the UI layout and and underlying apis.
Mar 6th, 2013, 04:43 AM
we had a similar task in our project. Since you are new I try to keep it as simple as possible.
First, you need to start the Job in a separate process. Thus, you need a separate application that is only concerned with running a job. In our case, it is called JobStarter and it was started using Runtime.getRuntime().exec(String command, String envp, File dir) ;. The command could be something like "java com.test.JobStarter jobname".
To display the currently running jobs in the UI, you can use the information stored in the job repository. It stores the state of job- and step-executions in the DB. You'll find all you need to know in the Spring Batch Reference Guide. Have a look at Appendix B. Meta-Data Schema and 4.2. Configuring a JobRepository. If you are not allowed to add new tables to the database (as in our case) you can simply use H2DB.
The last task is to decide how to deal with job parameters. In our case, the JobStarter is responsible for setting up the job parameters before the job is started.
If you are using JSP, you might want to pass on job parameters from the request (e.g. http://.../startjob.jsp?jobname=xxx;param_a=b;param_c=d) to the command (e.g. Runtime.getRuntime().exec("java com.test.JobStarter xxx b d", ...) ; )
Another possible solution is to add a new database table (e.g. table BATCH_JOB_CONFIG with columns JOB_ID, JOB_NAME, PARM_NAME, PARAM_VALUE) that is updated in the UI and read by the JobStarter.
Last edited by BjRi; Mar 6th, 2013 at 04:53 AM.