Announcement Announcement Module
Collapse
No announcement yet.
RollBack when we throw a custom exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RollBack when we throw a custom exception

    Hi,

    I'm using Spring Batch 1.1.0.

    I'm using listeners to log the exception. My problem is the transaction is getting rolled back when exception is thrown by the process, but transaction is not rolled back when we manually throw a custom exception.

    Why its behaving like this ?

    Please find my job configuration below

    Code:
    <bean id="agencyMergeJob" parent="simpleJob">
    		<!-- set restartable=false so that this job can be used by more than one test -->
    		<property name="restartable" value="true"  />
    		<property name="steps">
    		<list>
    		    <bean id="procbsln" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="procBslnItemReader" />
    				<property name="itemWriter" ref="statusChangeItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    			</bean>
    			<bean id="agencyMerge" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="hibernateItemReader" />
    				<property name="itemWriter" ref="hibernateItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    				<property name="listeners">
    					<list>
    						<ref bean="skipStepListener"/>
    						<ref bean="stepListener"/>
    					</list>
    				</property>
    			</bean>
    			<bean id="statusChange" parent="skipLimitStep">
    				<property name="skipLimit" value="99999"/>
    				<property name="itemReader" ref="statusItemReader" />
    				<property name="itemWriter" ref="statusChangeItemWriter" />
    				<property name="commitInterval" value="1" />
    				<property name="skippableExceptionClasses"	value="java.lang.Exception"/>
    				<property name="allowStartIfComplete" value="true" />
    				<property name="listeners">
    					<list>
    						<ref bean="skipStepListener"/>
    						<ref bean="stepListener"/>
    					</list>
    				</property>
    			</bean>		
    		</list>	
    		</property>
    	</bean>

    My custom exception extends exception
    Code:
    throw new CustomException(message,throwable);
    when i do like the above one, my transaction is not getting rolled back

    Correct me if im wrong.

  • #2
    Is your custom exception a checked exception? If so, there was an issue we fixed in 1.1.3 related to how the framework handles checked exceptions.

    Comment


    • #3
      Originally posted by lucasward View Post
      Is your custom exception a checked exception? If so, there was an issue we fixed in 1.1.3 related to how the framework handles checked exceptions.
      Yes Lucas, my custom exception is a checked exception.
      Will upgrade my spring batch version

      Comment


      • #4
        From where i can download 1.1.3 ?


        Originally posted by jayasimhan View Post
        Yes Lucas, my custom exception is a checked exception.
        Will upgrade my spring batch version

        Comment


        • #5
          I was using org.springframework.batch.item.support.DelegatingI temReader.

          This is being removed from version2. Is there any similar class in v2 ?

          Originally posted by jayasimhan View Post
          Yes Lucas, my custom exception is a checked exception.
          Will upgrade my spring batch version

          Comment

          Working...
          X