再遇org.apache.catalina.connector.ClientAbortException: java.net.SocketException: 断开的管道 (Write failed)
优付商户平台“付款记录”页面,商户操作员点击“下载结算凭证”按钮,系统会将所选条件的交易的回单文件以zip包的形式返回给浏览器页面。
由于程序涉及到复杂计算,同时涉及到读库、网络、磁盘IO,耗时比较长。为了防止重复请求,今天,我用redis分布式锁做了防重复提交控制。
@RequestMapping(value = "/downLoadBill") public void downLoadBill(HttpServletRequest request, HttpServletResponse response) throws Exception { UserVO userVO=(UserVO) request.getSession().getAttribute("userVO"); log.info("==MERCHANT==结算凭证下载,执行开始==企业id={}", userVO.getMERID()); response.setCharacterEncoding(Constant.CHARSET); String lockKey="downLoadBill:"+userVO.getMERID(); String lockValue = UUID.randomUUID().toString(); boolean getLock = JedisUtils.tryGetDistributedLock(lockKey, lockValue,15000); if (!getLock) { log.info("结算凭证下载中,请勿重复提交"); response.getWriter().write("您似乎进行了重复提交操作。请重新发起请求,因数据量大,希望您耐心等待系统响应!"); return; } .... OutputStream responseStream = new BufferedOutputStream(response.getOutputStream()); response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment;filename=" + new String(file.getName().getBytes("UTF-8"),"ISO-8859-1")); responseStream.write(buffer); responseStream.flush(); .... }
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » 再遇org.apache.catalina.connector.ClientAbortException: java.net.SocketException: 断开的管道 (Write failed)
自学咖网 » 再遇org.apache.catalina.connector.ClientAbortException: java.net.SocketException: 断开的管道 (Write failed)