Refactoring RetryItemProcessor
This commit is contained in:
parent
6dd702867e
commit
bc229a692e
|
@ -18,18 +18,19 @@ import java.io.IOException;
|
||||||
public class RetryItemProcessor implements ItemProcessor<Transaction, Transaction> {
|
public class RetryItemProcessor implements ItemProcessor<Transaction, Transaction> {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RetryItemProcessor.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(RetryItemProcessor.class);
|
||||||
|
|
||||||
|
private static final int TWO_SECONDS = 2000;
|
||||||
|
|
||||||
private CloseableHttpClient client;
|
private CloseableHttpClient client;
|
||||||
|
|
||||||
public RetryItemProcessor() {
|
public RetryItemProcessor() {
|
||||||
final RequestConfig config = RequestConfig.custom().setConnectTimeout(2 * 1000).build();
|
final RequestConfig config = RequestConfig.custom().setConnectTimeout(TWO_SECONDS).build();
|
||||||
client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Transaction process(Transaction transaction) throws IOException, JSONException {
|
public Transaction process(Transaction transaction) throws IOException, JSONException {
|
||||||
LOGGER.info("Attempting to process user with id={}", transaction.getUserId());
|
LOGGER.info("Attempting to process user with id={}", transaction.getUserId());
|
||||||
System.out.println("Attempting to process user with id=" + transaction.getUserId());
|
|
||||||
HttpResponse response = fetchMoreUserDetails(transaction.getUserId());
|
HttpResponse response = fetchMoreUserDetails(transaction.getUserId());
|
||||||
|
|
||||||
//parse user's age and postCode from response and update transaction
|
//parse user's age and postCode from response and update transaction
|
||||||
|
|
Loading…
Reference in New Issue