com.naver.spring.batch.extension.item.rest.AbstractAsyncRestItemReader Maven / Gradle / Ivy
/*
Copyright 2018 NAVER Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.naver.spring.batch.extension.item.rest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.util.Assert;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.client.AsyncRestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
*
* 페이징 처리된 Rest API 로부터 데이터를 읽어 들이기 위한 Item Reader.
*
* 여러개의 variables 로부터 요청하는 경우 {@link AsyncListenableTaskExecutor} 를 통해 Async 요청을 수행한다.
* response 에 대해서 {@link #convertResponse(ResponseEntity, Map)} ()} 를 통해 Object 매핑 방식을 하위 클래스에서 구현한다.
*
*
* @author yongkyu.lee
* @since 0.1
*/
public abstract class AbstractAsyncRestItemReader implements ItemReader, InitializingBean {
private Logger log = LoggerFactory.getLogger(AbstractAsyncRestItemReader.class);
private AsyncRestTemplate asyncRestTemplate;
private Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy