赞
踩
- /**
- * sendServerDataDTO待发送的数据类;
- */
- public SendServerReturnMsgDTO sendData(SendServerDataDTO sendServerDataDTO) {
- String data = FastJsonUtils.obj2JsonStr(sendServerDataDTO);
-
- SendServerReturnMsgDTO sendServerReturnMsgDTO = new SendServerReturnMsgDTO();
-
- try {
- URL url = new URL(sendServerDataDTO.getUrl());
- log.debug("kafkaUrl:{},topic:{}",url,sendServerDataDTO.getTopic());
- // 将url 以 open方法返回的urlConnection 连接强转为HttpURLConnection连接 (标识一个url所引用的远程对象连接)
- // 此时cnnection只是为一个连接对象,待连接中
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- // 设置连接输出流为true,默认false (post 请求是以流的方式隐式的传递参数)
- // 设置通用的请求属性
- // 设置建立连接的超时时间
- connection.setConnectTimeout(30000);
- // 设置传递数据的超时时间
- connection.setReadTimeout(30000);
- connection.setRequestProperty("accept", &

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。