Announcement Announcement Module
No announcement yet.
Defining an abstract job with properties Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Defining an abstract job with properties


    I'm currently defining a default abstract job. That job will be extended by concrete jobs. The default abstract job may contain properties like: skip-policy, start-limit, etc.

    However, it becomes difficult to right that configuration. I try something like this:
    	<bean id="skipPolicy" class="com.bsb.sf.batch.DefaultSkipPolicyTest" />
    	<bean id="defaultJobTasklet" abstract="true" class="org.springframework.batch.core.step.tasklet.TaskletStep">       
    	<bean id="defaultChunkProcessor" class="org.springframework.batch.core.step.item.FaultTolerantChunkProcessor" abstract="true">
    		<property name="ProcessSkipPolicy" value="skipPolicy" />
    	<bean id="defaultMainStep" abstract="true" class="org.springframework.batch.core.step.item.ChunkOrientedTasklet">
    		<constructor-arg index="0">
    			<bean id="chunkProcessor" class="org.springframework.batch.core.step.item.FaultTolerantChunkProcessor" parent="defaultChunkProcessor">
    				<constructor-arg index="0" ref="exceptionItemProcessor" />
    				<constructor-arg index="1" ref="itemWriterCounter" />
    				<property name="ProcessSkipPolicy" value="skipPolicy" />
    		<constructor-arg index="1" ref="chunkProvider" /> 
    	<bean id="defaultBatchJob" abstract="true" class="org.springframework.batch.core.job.SimpleJob">
    		<property name="steps">
    				<bean parent="defaultJobTasklet">
    					<property name="tasklet" ref="defaultMainStep" />
    (This solution is incomplete and some parts must be redefined).

    As you can see, this solution is highly linked to a certain solution. Is there any way to define an abstract job with that properties (skip-policy, start-limit, allow-start-if-complete) ?

    A solution could be to define that properties in jobs and not only in chunks:

    <job id="defaultBatchJob" abstract="true" skip-policy="myPackage.MyClass" />

    Another partial solution for skipability could be the creation of two interface SkippableException and NonSkippableException. Exception implementing that interfaces will be automatically ignored, or not.


    Last edited by sebge2; Jan 7th, 2010, 05:18 AM.

  • #2
    I'm not really sure what it is you are trying to achieve. The properties that you mentioned specifically (skip-policy, start-limit, allow-start-if-complete) are all properties of a Step, not of a Job, and there is good support in the Batch XML namespace for abstract step definitions. You can also use the beans namespace if you prefer (as you did in the sample you posted).


    • #3
      I've found a solution (I've not tried yet):

      	<bean id="fatherStep"
      		class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean" abstract="true">
      		<property name="transactionManager" ref="transactionManager" />
      		<property name="jobRepository" ref="jobRepository" />
      		<property name="backOffPolicy">
      			<bean class="org.springframework.batch.retry.backoff.FixedBackOffPolicy">
      				<property name="backOffPeriod" value="8000" />
      		<property name="retryableExceptionClasses">
      		<property name="retryLimit" value="3" />
      		<property name="retryPolicy" ref="defaultRetryPolicy" />
      		<property name="skipPolicy" ref="defaultSkipPolicy" />
      Like that I can define an abstract (i.e., predefined) chunk with a default skip policy and retry policy. New chunk may inherit from it.

      related to
      Last edited by sebge2; Jan 11th, 2010, 04:38 AM.