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

  • Defining an abstract job with properties

    Hello,

    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:
    Code:
    	<bean id="skipPolicy" class="com.bsb.sf.batch.DefaultSkipPolicyTest" />
    
    	<bean id="defaultJobTasklet" abstract="true" class="org.springframework.batch.core.step.tasklet.TaskletStep">       
    	
    	</bean> 
    	<bean id="defaultChunkProcessor" class="org.springframework.batch.core.step.item.FaultTolerantChunkProcessor" abstract="true">
    		<property name="ProcessSkipPolicy" value="skipPolicy" />
    	</bean>	
    	
    	<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" />
    			</bean>
    		</constructor-arg>
    		<constructor-arg index="1" ref="chunkProvider" /> 
    	</bean>
    
    	<bean id="defaultBatchJob" abstract="true" class="org.springframework.batch.core.job.SimpleJob">
    		<property name="steps">
    			<list>
    				<bean parent="defaultJobTasklet">
    					<property name="tasklet" ref="defaultMainStep" />
    				</bean>
    			</list>
    		</property>
    	</bean>
    (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.


    Best,

    Sébastien
    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).

    Comment


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

      Code:
      	<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" />
      			</bean>
      		</property>
      		
      		<property name="retryableExceptionClasses">
      			<map>
      			</map>
      		</property>
      		<property name="retryLimit" value="3" />
      		<property name="retryPolicy" ref="defaultRetryPolicy" />
      		<property name="skipPolicy" ref="defaultSkipPolicy" />
      	</bean>
      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 https://jira.springsource.org/browse/BATCH-1139
      Last edited by sebge2; Jan 11th, 2010, 04:38 AM.

      Comment

      Working...
      X