Announcement Announcement Module
No announcement yet.
Configure job incrementer and as launchable Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configure job incrementer and as launchable

    Hello, I am rather new to Spring Batch Admin and I am quite happy with using Spring Batch for my task. However, I can't seem to configure my job to:

    1. Register by Spring Batch Admin
    2. Set job to be launchable by the GUI
    3. Set the incrementer for the jobs.

    <job id="pdorderJob" parent="simpleJob" incrementer="incrementer">
    		<step id="convertToVendorOrderFormat" parent="simpleStep">
    				<chunk reader="orderDetailReader" processor="convertToVendorProcessor" writer="orderDetailWriter"/>
    <job id="orderStatus" parent="simpleJob" incrementer="incrementer">
    		<!-- 1. Use scheduler for order status --> 
    		<step id="queryOrderStatus" parent="simpleStep" next="confirmShipping">
    				<chunk reader="orderStatusSqlItemReader" processor="queryOrderStatusProcessor" writer="queryOrderStatusWriter"/>
    		<!-- 2. Query database for status = 7, and call confirm_shipping -->
    		<step id="confirmShipping" parent="simpleStep">
    				<chunk reader="confirmShippingSqlItemReader" processor="confirmShippingProcessor" writer="queryOrderStatusWriter"/>
    				<listener ref="noWorkFoundStepExecutionListener"/>
    		<fail on="FAILED" exit-code="NOTHING SHIPPED"/>
    <beans:bean id="simpleJob" class="org.springframework.batch.core.job.SimpleJob"
    		<beans:property name="jobRepository" ref="jobRepository" />
    		<beans:property name="restartable" value="true" />
    <beans:bean id="simpleStep"
    	<beans:property name="transactionManager" ref="transactionManager" />
    	<beans:property name="jobRepository" ref="jobRepository" />
    	<beans:property name="startLimit" value="100" />
    	<beans:property name="commitInterval" value="1" />
    <beans:bean id="incrementer" class="com.pictage.provendirect.domain.order.internal.TrivialJobParametersIncrementer"/>
    To enable Spring Batch Admin, I followed the steps to
    • Create a war project with an index.jsp and a web.xml (from the sample or from the spring-batch-admin-resources.jar).
    • Include the spring-batch-admin-*.jar files in WEB-INF/lib. In the sample this is done simply by making the WAR depend on those jar files in the Maven pom.
    • Optionally add your own jobs in the classpath under META-INF/spring/batch/jobs/*.xml.

    I place the configuration file in src/main/resources/META-INF/batch/jobs/pdorderJob.xml

    I copy the abstract SimpleJob, SimpleStep and TrivalJobParametersIncrementer from the Spring Batch Admin example with STS. And I researched on the configuration (module-context.xml) in the example. All three jobs, job1, job2, and infinite, are launchable and has Incrementable.

    How do you configure jobs to be launchable and incrementable? My first job, pdorder show up under http://localhost:8080/spring-batch-simple/jobs, but not the second one, orderStatus, does not. And they are both inside the same xml file configuration, pdorderJob.xml Am I missing something?

    I am using 1.2.0.RELEASE of Spring Batch Admin. Any help would be greatly appreciated. Thanks for such an awesome product.

  • #2
    Bootstrapping Magic

    Ok, it turns out Spring Batch Admin was reading data that is already existing in the batch_* tables. From my home page http://localhost:8080/{ArtifactID}, in the URL /jobs, it said

    "List the jobs known to the application. If they are configured in this application they are launchable, otherwise not (i.e. if they have been executed offline)"
    So since I have existing data in the tables, all my jobs are not launchable. After I remove all the batch_* tables and upload my job configurable in the url:
    http://localhost:8080/{ArtifactID}/configuration, my jobs show up as launchable and executable.

    However, that would mean I have to erase my tables every time I start my server. I notices there is a batch-{-Denvironment}.properties file that get read. Inside there are "batch.schema.script", "batch.drop.script", "" and "". But I can't get them to read the script (File Not Found). So I have been setting init to be false.

    While it was cool to upload configuration file and have the jobs show up, I was hoping that my jobs will be read if I put it in " classpath under META-INF/spring/batch/jobs/*.xml." like mentioned in the documentation. Am I missing something?

    Also, I copied the file service-context.xml and it has a bean definition "/steps/step1" as httpinvokerServerExporter What does it do?

    Any input would be appreciated. Thank you.


    • #3
      After several round of digging, I was able to load the job file. I have to place my job file in /META-INF/spring/batch/jobs/ folder not /META-INF/batch/ Also, in order for my jobLauncher, jobRepository, dataSource, etc. to get discover at load time. I have to put it in /spring/batch/bootstrap/**/