fix: 发送OA消息的请求添加超时时间为2分钟,发送失败后的延迟时间设为10分钟
This commit is contained in:
@@ -144,7 +144,7 @@ public class SendDeleteMQService {
|
|||||||
private void restSendDoneTodo(String object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
private void restSendDoneTodo(String object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
||||||
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
||||||
if(againNumNew < 6){
|
if(againNumNew < 6){
|
||||||
Thread.sleep(3000);
|
Thread.sleep(600000);
|
||||||
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class SendDoneMQService {
|
|||||||
private void restSendDoneTodo(NotifyTodoSendContext object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
private void restSendDoneTodo(NotifyTodoSendContext object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
||||||
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
// 发送失败连续持续3次, 如果在失败等待1个小时后重试3次
|
||||||
if(againNumNew < 6){
|
if(againNumNew < 6){
|
||||||
Thread.sleep(3000);
|
Thread.sleep(600000);
|
||||||
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class SendMQService {
|
|||||||
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew,String operMesg) throws Exception{
|
||||||
// 失败次数小于6次,放入失败队列延迟消费
|
// 失败次数小于6次,放入失败队列延迟消费
|
||||||
if((againNumNew < 6)){
|
if((againNumNew < 6)){
|
||||||
Thread.sleep(3000);
|
Thread.sleep(600000);
|
||||||
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
logger.info("发送失败连续持续"+againNumNew+"次,存入延迟重试队列!!!!!!!!!");
|
||||||
}else {
|
}else {
|
||||||
logger.info("发送失败连续持续"+againNumNew+"次!!");
|
logger.info("发送失败连续持续"+againNumNew+"次!!");
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ public class SendToBeReadMQService {
|
|||||||
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew, String operMesg) throws Exception {
|
private void restSendTodo(BusProcessNew object, SimpleDateFormat sdf, SendTodoLog sendTodoLog, int againNumNew, String operMesg) throws Exception {
|
||||||
// 失败次数小于6次,放入失败队列延迟消费
|
// 失败次数小于6次,放入失败队列延迟消费
|
||||||
if ((againNumNew < 6)) {
|
if ((againNumNew < 6)) {
|
||||||
Thread.sleep(3000);
|
// 延迟10分钟
|
||||||
|
Thread.sleep(600000);
|
||||||
logger.info("发送失败连续持续" + againNumNew + "次,存入延迟重试队列!!!!!!!!!");
|
logger.info("发送失败连续持续" + againNumNew + "次,存入延迟重试队列!!!!!!!!!");
|
||||||
} else {
|
} else {
|
||||||
logger.info("发送失败连续持续" + againNumNew + "次!!");
|
logger.info("发送失败连续持续" + againNumNew + "次!!");
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.io.File;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OkHttpUtil {
|
public class OkHttpUtil {
|
||||||
@@ -250,6 +251,10 @@ public class OkHttpUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String postForJson(String url, String json, Map<String, String> headerParams){
|
public String postForJson(String url, String json, Map<String, String> headerParams){
|
||||||
|
OkHttpClient client = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(2, TimeUnit.MINUTES)//设置连接超时时间
|
||||||
|
.readTimeout(2, TimeUnit.MINUTES)//设置读取超时时间
|
||||||
|
.build();
|
||||||
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json);
|
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json);
|
||||||
String responseBody = "";
|
String responseBody = "";
|
||||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||||
@@ -257,20 +262,14 @@ public class OkHttpUtil {
|
|||||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
Request request = requestBuilder.post(requestBody).build();
|
Request request = requestBuilder.post(requestBody).build();
|
||||||
Response response = null;
|
try (Response response = client.newCall(request).execute()) {
|
||||||
try {
|
|
||||||
response = okHttpClient.newCall(request).execute();
|
|
||||||
int status = response.code();
|
int status = response.code();
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
return response.body().string();
|
return response.body().string();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
|
||||||
return "okhttp post error >> ex = {} "+ e.getMessage();
|
return "okhttp post error >> ex = {} " + e.getMessage();
|
||||||
} finally {
|
|
||||||
if (response != null) {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return responseBody;
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user