Code example for ThreadSafeClientConnManager

Methods: setDefaultMaxPerRoute, setMaxTotal

0
	private HttpClient httpClient;
	 
	private static final Log logger = LogFactory.getLog(TaobaoCommentServiceImpl.class);
	 
	public TaobaoCommentServiceImpl() { 
		ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager();
		connManager.setDefaultMaxPerRoute(20);
		connManager.setMaxTotal(200);
		httpClient = new DefaultHttpClient(connManager);
	} 
	 
	@Override 
	public List<TaobaoCommentDTO> getItemComments(Long itemNativeId, Long sellerId,
			TaobaoCommentEnum commentEnum) {
		if (isInvalidId(itemNativeId) || isInvalidId(sellerId) || commentEnum == null) {
			return new ArrayList<TaobaoCommentDTO>();
		} 
		Map<String, Object> params = commentEnum.getCommentRequestParams(itemNativeId, sellerId);
		String reqUrl = commentEnum.getItemCommentAjaxUrl(params);
		String commentJson = executeRequest(reqUrl);
Stop searching for code, let great code find you!  Add Codota to your java IDE