Solved

spring batch

Posted on 2014-01-06
4
791 Views
Last Modified: 2014-01-12
Hello,

can anybody tell what is the reason why  the skip limit is ignored.... if skip limit is set to 1 and if i have 3 bad record.... it does not stop after processing first record...........

I am trying to call the skip by executor class

but still it gives the same error.....

 Executor.java

o    try {

o    // job execution

o    }catch (SkipLimitExceededException skipLimitExceededException) {

§  System.exit(1);

o    } catch (Exception exception) {

§  if (log.isErrorEnabled()) {

§  log.error("Error performing job" + exception.getMessage());

o    }

o    log.debug(exception);

 

o    }finally {

o    context.close();

o    }

 

o    System.exit(0);

 

o   }// end of Executor.java

Open in new window


public boolean shouldSkip(Throwable throwable, int skipCount)
		throws SkipLimitExceededException{
		StringBuffer stringBuffer = new StringBuffer();
		
		if (throwable instanceof FlatFileParseException) {
			int linenumber = ((FlatFileParseException) throwable).getLineNumber();
			String input = ((FlatFileParseException) throwable).getInput();
			stringBuffer.append("Parsing exception encountered on line #" + linenumber + "; input = " + input);
			log.error(stringBuffer.toString());
		}else {
			stringBuffer.append(throwable.getMessage());
			log.error(stringBuffer.toString());
			log.debug(throwable);
		}
		try{
		if (getSkipLimit() <= skipCount && getSkipLimit() > 0) {
			SkipLimitExceededException skipLimitExceededException = new SkipLimitExceededException(
					skipCount, throwable);
			log.error("Skip Limit Exceeded "+skipLimit);
			log.debug("Skip Limit Exceeded", skipLimitExceededException);
			throw skipLimitExceededException;
			
		}
		}catch(SkipLimitExceededException skipLimitExceededException){
			
		}
		
		return true;
	}

Open in new window



      

         <bean id="midFlatFileLineTokenizer"

                        class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">

                               <property name="delimiter" value="${com.met.midutiliy.delimiter:|}" />
                               <property name="names" value="${com.met.midutiliy.field.list:fromMemberID, toMemberID}" />

 <property name="strict" value="false" />
 </bean>

Open in new window

0
Comment
Question by:roy_sanu
  • 3
4 Comments
 
LVL 16

Expert Comment

by:krakatoa
ID: 39758982
Not sure. But this :

if (getSkipLimit() <= skipCount && getSkipLimit() > 0) {

Open in new window


could anyway be simply :

if (skipCount >= getSkipLimit()){

Open in new window

0
 

Author Comment

by:roy_sanu
ID: 39759755


my errors are getting displayed on the console, but i do not want to display in the console. i understand that using throwable exception i am getting error in the console How i can get rid off it... or how throwable can be logged

your comments will be highly appreciable...........

Thanks in advance...........



Encountered an error executing the step
org.springframework.batch.core.step.skip.SkipLimitExceededException: Skip limit of '2' exceeded
	at com.listener.MIDSkipPolicy.shouldSkip(MIDSkipPolicy.java:53)
	at org.springframework.batch.core.step.skip.CompositeSkipPolicy.shouldSkip(CompositeSkipPolicy.java:41)
	at org.springframework.batch.core.step.skip.ExceptionClassifierSkipPolicy.shouldSkip(ExceptionClassifierSkipPolicy.java:70)
	at org.springframework.batch.core.step.item.FaultTolerantChunkProvider.shouldSkip(FaultTolerantChunkProvider.java:134)
	at org.springframework.batch.core.step.item.FaultTolerantChunkProvider.read(FaultTolerantChunkProvider.java:91)
	at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:114)
	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
	at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:108)
	at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:69)
	at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:395)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)

Open in new window

0
 

Accepted Solution

by:
roy_sanu earned 0 total points
ID: 39762781
Removed this part of the code it is working fine
		try{


     }catch(SkipLimitExceededException skipLimitExceededException){

Open in new window


Thanks
0
 

Author Closing Comment

by:roy_sanu
ID: 39774460
removal of the try and catch block of  }catch(SkipLimitExceededException skipLimitExceededException){
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changePi Challenge 15 75
countHi2 challenge 7 44
unix in java example 9 39
JUnit 4 @Before and @BeforeClass differences 3 19
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now