Refactoring RetryItemProcessor

This commit is contained in:
Shubhra Srivastava 2020-02-11 07:28:56 +05:30 committed by GitHub
parent 6dd702867e
commit bc229a692e
1 changed files with 4 additions and 3 deletions

View File

@ -19,17 +19,18 @@ public class RetryItemProcessor implements ItemProcessor<Transaction, Transactio
private static final Logger LOGGER = LoggerFactory.getLogger(RetryItemProcessor.class);
private static final int TWO_SECONDS = 2000;
private CloseableHttpClient client;
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();
}
@Override
public Transaction process(Transaction transaction) throws IOException, JSONException {
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());
//parse user's age and postCode from response and update transaction