@Test public void testItemLookup02() throws Exception { int threadNum = 50; ExecutorService exec = Executors.newFixedThreadPool(5); List<Result> results = new ArrayList<Result>(); String[] ids = { "489471499X", "489471499X", "4798024031" }; for (int i = 0; i < threadNum; i++) { final String id = ids[i % ids.length]; Future<ItemLookupResponse> res = exec .submit(new Callable<ItemLookupResponse>() { @Override public ItemLookupResponse call() throws Exception { ItemLookupRequest request = new ItemLookupRequest(); request.getItemId().add(id); request.getResponseGroup().add("Small"); return requester.itemLookup(request); } }); Result result = new Result(); result.res = res; result.expectedId = id; results.add(result); } for (Result r : results) { ItemLookupResponse response = r.res.get(); assertNotNull(response); assertNotNull(response.getItems()); assertTrue(response.getItems().size() == 1); assertNotNull(response.getItems().get(0).getItem()); assertTrue(response.getItems().get(0).getItem().size() == 1); Item item = response.getItems().get(0).getItem().get(0); assertEquals(r.expectedId, item.getASIN()); assertNotNull(item.getItemAttributes()); } exec.shutdown(); }
@Override public ItemLookupResponse itemLookup(ItemLookupRequest request) { final AWSECommerceServicePortType port = preparePort(); final ItemLookup itemLookup = prepareItemLookup(request); ItemLookupResponse response = invokeWithRetry(new WebServiceInvoker<ItemLookupResponse>() { @Override public ItemLookupResponse invoke() throws WebServiceException { return port.itemLookup(itemLookup); } }); return response; }
AwsApaRequesterImpl implements AwsApaRequester { @Override public ItemLookupResponse itemLookup(ItemLookupRequest request) { final AWSECommerceServicePortType port = preparePort(); final ItemLookup itemLookup = prepareItemLookup(request); ItemLookupResponse response = invokeWithRetry(new WebServiceInvoker<ItemLookupResponse>() { @Override public ItemLookupResponse invoke() throws WebServiceException { return port.itemLookup(itemLookup); } }); return response; } }
AwsApaRequesterImpl implements AwsApaRequester { @Override public ItemLookupResponse itemLookup(ItemLookupRequest request) { final AWSECommerceServicePortType port = preparePort(); final ItemLookup itemLookup = prepareItemLookup(request); ItemLookupResponse response = invokeWithRetry(new WebServiceInvoker<ItemLookupResponse>() { @Override public ItemLookupResponse invoke() throws WebServiceException { return port.itemLookup(itemLookup); } }); return response; } AwsApaRequesterImpl();  AwsApaRequesterImpl(String endpoint, String accessKeyId,
                               String secretAccessKey, String associateTag); }
AwsApaRequesterImpl implements AwsApaRequester { @Override public ItemLookupResponse itemLookup(ItemLookupRequest request) { final AWSECommerceServicePortType port = preparePort(); final ItemLookup itemLookup = prepareItemLookup(request); ItemLookupResponse response = invokeWithRetry(new WebServiceInvoker<ItemLookupResponse>() { @Override public ItemLookupResponse invoke() throws WebServiceException { return port.itemLookup(itemLookup); } }); return response; } AwsApaRequesterImpl();  AwsApaRequesterImpl(String endpoint, String accessKeyId,
                               String secretAccessKey, String associateTag); @Override ItemSearchResponse itemSearch(ItemSearchRequest request); @Override Response<ItemSearchResponse> itemSearchAsync(
            ItemSearchRequest request); T invokeWithRetry(WebServiceInvoker<T> invoker); @Override ItemLookupResponse itemLookup(ItemLookupRequest request); @Override Response<ItemLookupResponse> itemLookupAsync(
            ItemLookupRequest request); T getResponseWithRetry(final Response<T> res); int getRetryCount(); void setRetryCount(int retryCount); long getRetryInterval(); void setRetryInterval(long retryInterval); }
AwsApaRequesterImpl implements AwsApaRequester { @Override public ItemLookupResponse itemLookup(ItemLookupRequest request) { final AWSECommerceServicePortType port = preparePort(); final ItemLookup itemLookup = prepareItemLookup(request); ItemLookupResponse response = invokeWithRetry(new WebServiceInvoker<ItemLookupResponse>() { @Override public ItemLookupResponse invoke() throws WebServiceException { return port.itemLookup(itemLookup); } }); return response; } AwsApaRequesterImpl();  AwsApaRequesterImpl(String endpoint, String accessKeyId,
                               String secretAccessKey, String associateTag); @Override ItemSearchResponse itemSearch(ItemSearchRequest request); @Override Response<ItemSearchResponse> itemSearchAsync(
            ItemSearchRequest request); T invokeWithRetry(WebServiceInvoker<T> invoker); @Override ItemLookupResponse itemLookup(ItemLookupRequest request); @Override Response<ItemLookupResponse> itemLookupAsync(
            ItemLookupRequest request); T getResponseWithRetry(final Response<T> res); int getRetryCount(); void setRetryCount(int retryCount); long getRetryInterval(); void setRetryInterval(long retryInterval);  }