Java Code Examples for org.springframework.batch.item.ParseException

The following examples show how to use org.springframework.batch.item.ParseException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SpringBootBucket   Source File: BudgetVtollConfig.java    License: MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "vtollStep1")
    public Step vtollStep1(StepBuilderFactory stepBuilderFactory,
                           @Qualifier("vtollReader") ItemReader<BudgetVtoll> reader,
                           @Qualifier("vtollWriter") ItemWriter<BudgetVtoll> writer,
                           @Qualifier("vtollProcessor") ItemProcessor<BudgetVtoll, BudgetVtoll> processor) {
        return stepBuilderFactory
                .get("vtollStep1")
                .<BudgetVtoll, BudgetVtoll>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example 2
Source Project: SpringBootBucket   Source File: CantonConfig.java    License: MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "cantonStep1")
    public Step cantonStep1(StepBuilderFactory stepBuilderFactory,
                           @Qualifier("cantonReader") ItemReader<Canton> reader,
                           @Qualifier("cantonWriter") ItemWriter<Canton> writer,
                           @Qualifier("cantonProcessor") ItemProcessor<Canton, Canton> processor) {
        return stepBuilderFactory
                .get("cantonStep1")
                .<Canton, Canton>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example 3
Source Project: SpringBootBucket   Source File: LogConfig.java    License: MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "logStep1")
    public Step logStep1(StepBuilderFactory stepBuilderFactory,
                         @Qualifier("logReader") ItemReader<Log> reader,
                         @Qualifier("logWriter") ItemWriter<Log> writer,
                         @Qualifier("logProcessor") ItemProcessor<Log, Log> processor) {
        return stepBuilderFactory
                .get("logStep1")
                .<Log, Log>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example 4
Source Project: SpringBootBucket   Source File: AppConfig.java    License: MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "zappStep1")
    public Step zappStep1(StepBuilderFactory stepBuilderFactory,
                          @Qualifier("appReader") ItemReader<App> reader,
                          @Qualifier("appWriter") ItemWriter<App> writer,
                          @Qualifier("appProcessor") ItemProcessor<App, App> processor) {
        return stepBuilderFactory
                .get("zappStep1")
                .<App, App>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example 5
Source Project: seed   Source File: SeedMultiResourceItemReader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Reads the next item, jumping to next resource if necessary.
 */
@Override
public T read() throws Exception, UnexpectedInputException, ParseException {

    if (noInput) {
        return null;
    }

    // If there is no resource, then this is the first item, set the current
    // resource to 0 and open the first delegate.
    if (currentResource == -1) {
        currentResource = 0;
        delegate.setResource(resources[currentResource]);
        delegate.open(new ExecutionContext());
    }

    return readNextItem();
}
 
Example 6
Source Project: olat   Source File: SynchronizationReaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void read_twoCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.chekImportedData()).thenReturn(true);
    List<Long> CreatedSapCourcesIds = new ArrayList<Long>();
    CreatedSapCourcesIds.add(100L);
    CreatedSapCourcesIds.add(200L);
    when(daoManagerMock.getAllCreatedSapCourcesIds()).thenReturn(CreatedSapCourcesIds);

    CampusCourseImportTO courseMock1 = mock(CampusCourseImportTO.class);
    CampusCourseImportTO courseMock2 = mock(CampusCourseImportTO.class);
    when(daoManagerMock.getSapCampusCourse(100L)).thenReturn(courseMock1);
    when(daoManagerMock.getSapCampusCourse(200L)).thenReturn(courseMock2);

    synchronizationReaderTestObject.init();
    // The first read delivers the first course
    assertNotNull(synchronizationReaderTestObject.read());
    // The second read delivers the second course
    assertNotNull(synchronizationReaderTestObject.read());
    // The third read delivers null
    assertNull(synchronizationReaderTestObject.read());
}
 
Example 7
Source Project: olat   Source File: StudentMappingReaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void read_twoStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    List<Student> twoStudentsList = new ArrayList<Student>();
    Student studentMock1 = mock(Student.class);
    Student studentMock2 = mock(Student.class);
    twoStudentsList.add(studentMock1);
    twoStudentsList.add(studentMock2);
    when(daoManagerMock.getAllStudents()).thenReturn(twoStudentsList);
    studentMappingReaderTestObject.init();
    // The first read delivers the first student
    assertNotNull(studentMappingReaderTestObject.read());
    // The second read delivers the second student
    assertNotNull(studentMappingReaderTestObject.read());
    // The third read delivers null
    assertNull(studentMappingReaderTestObject.read());
}
 
Example 8
Source Project: olat   Source File: LecturerMappingReaderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void read_twoLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    List<Lecturer> twoLecturersList = new ArrayList<Lecturer>();
    Lecturer lecturerMock1 = mock(Lecturer.class);
    Lecturer lecturerMock2 = mock(Lecturer.class);
    twoLecturersList.add(lecturerMock1);
    twoLecturersList.add(lecturerMock2);
    when(daoManagerMock.getAllLecturers()).thenReturn(twoLecturersList);
    lecturerMappingReaderTestObject.init();
    // The first read delivers the first lecturer
    assertNotNull(lecturerMappingReaderTestObject.read());
    // The second read delivers the second lecturer
    assertNotNull(lecturerMappingReaderTestObject.read());
    // The third read delivers null
    assertNull(lecturerMappingReaderTestObject.read());
}
 
Example 9
@Override
public Item read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
	if (readerTransactional) {
		businessMetrics.increment(MetricNames.READ_COUNT.getName());
		businessMetrics.submit(MetricNames.READ_GAUGE.getName(), 5);
	} else {
		businessMetrics.incrementNonTransactional(MetricNames.READ_COUNT.getName());
		businessMetrics.submitNonTransactional(MetricNames.READ_GAUGE.getName(), 5);
	}
	Item item = delegate.read();
	if (item != null && item.getActions().contains(Action.FAIL_ON_READ)) {
		throw new MetricsTestException(Action.FAIL_ON_READ);
	}
	LOGGER.debug("Read item: {}", item);
	return item;
}
 
Example 10
Source Project: spring-cloud-task   Source File: SkipItemReader.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object read() throws Exception, UnexpectedInputException, ParseException,
		NonTransientResourceException {
	String result = "1";
	if (this.failCount < 2) {
		this.failCount++;
		throw new IllegalStateException("Reader FOOBAR");
	}
	if (this.finished) {
		result = null;
	}
	this.finished = true;
	return result;
}
 
Example 11
Source Project: olat   Source File: SynchronizationReader.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reads a {@link CampusCourseImportTo} via the {@link DaoManager} with the given course id from the list of the sapCoursesIds. <br>
 * It returns null at the end of the list of the sapCoursesIds
 */
public CampusCourseImportTO read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
    if (ListUtil.isNotBlank(sapCoursesIds)) {
        return daoManager.getSapCampusCourse(sapCoursesIds.remove(0));
    }
    return null;
}
 
Example 12
Source Project: blog   Source File: HelloWorldReader.java    License: MIT License 5 votes vote down vote up
public Object read() throws Exception, UnexpectedInputException,
        ParseException {
    Object o = null;
    if (executionTimes > 0) {
        executionTimes--;
        o = new Object();
    }
    return o;
}
 
Example 13
Source Project: olat   Source File: SynchronizationReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_nullCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllCreatedSapCources()).thenReturn(null);
    synchronizationReaderTestObject.init();
    assertNull(synchronizationReaderTestObject.read());
}
 
Example 14
Source Project: olat   Source File: SynchronizationReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_emptyCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllCreatedSapCources()).thenReturn(Collections.emptyList());
    synchronizationReaderTestObject.init();
    assertNull(synchronizationReaderTestObject.read());
}
 
Example 15
Source Project: olat   Source File: StudentMappingReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_nullStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllStudents()).thenReturn(null);
    studentMappingReaderTestObject.init();
    assertNull(studentMappingReaderTestObject.read());
}
 
Example 16
Source Project: olat   Source File: StudentMappingReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_emptyStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllStudents()).thenReturn(Collections.emptyList());
    studentMappingReaderTestObject.init();
    assertNull(studentMappingReaderTestObject.read());
}
 
Example 17
Source Project: olat   Source File: LecturerMappingReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_nullLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllLecturers()).thenReturn(null);
    lecturerMappingReaderTestObject.init();
    assertNull(lecturerMappingReaderTestObject.read());
}
 
Example 18
Source Project: olat   Source File: LecturerMappingReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void read_emptyLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
    when(daoManagerMock.getAllLecturers()).thenReturn(Collections.emptyList());
    lecturerMappingReaderTestObject.init();
    assertNull(lecturerMappingReaderTestObject.read());
}
 
Example 19
Source Project: pinpoint   Source File: AgentCountReader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationAgentsList read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
    return queue.poll();
}