Commit 80e66d76 authored by yanzg's avatar yanzg

消除成功接收处理

parent 6851c5fb
...@@ -6,10 +6,14 @@ import java.util.*; ...@@ -6,10 +6,14 @@ import java.util.*;
/** /**
* 执行队列的数据,会根据其中的执行函数,自动优化执行循序 * 执行队列的数据,会根据其中的执行函数,自动优化执行循序
*
* @author 颜佐光 * @author 颜佐光
*/ */
public final class RunnableListAuto { public final class RunnableListAuto {
/**
* 最小线程数量
*/
public static final int MIN_THREAD = 2;
/** /**
* 是否打印线程日志 * 是否打印线程日志
*/ */
...@@ -107,7 +111,7 @@ public final class RunnableListAuto { ...@@ -107,7 +111,7 @@ public final class RunnableListAuto {
// 计算线程数量 // 计算线程数量
maxAvg = Math.max(maxAvg, 1); maxAvg = Math.max(maxAvg, 1);
int threadCount = zeroCount + (int) (totalAvg / maxAvg); int threadCount = zeroCount + (int) (totalAvg / maxAvg);
if (threadCount > 2) { if (threadCount > MIN_THREAD) {
threadCount = threadCount - 1; threadCount = threadCount - 1;
} }
threadCount = Math.min(threadCount, methods.size()); threadCount = Math.min(threadCount, methods.size());
......
...@@ -7,6 +7,7 @@ import java.util.Date; ...@@ -7,6 +7,7 @@ import java.util.Date;
/** /**
* 自动执行队列的某一项 * 自动执行队列的某一项
*
* @author 颜佐光 * @author 颜佐光
*/ */
public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> { public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> {
...@@ -82,9 +83,10 @@ public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> { ...@@ -82,9 +83,10 @@ public class RunnableListAutoItem implements Comparable<RunnableListAutoItem> {
* 则Time = time/2, count = count/2; * 则Time = time/2, count = count/2;
*/ */
private synchronized void init() { private synchronized void init() {
if (this.time > Long.MAX_VALUE / 2 || this.count > Integer.MAX_VALUE / 2) { if (this.time > Long.MAX_VALUE / RunnableListAuto.MIN_THREAD
this.time = this.time / 2; || this.count > Integer.MAX_VALUE / RunnableListAuto.MIN_THREAD) {
this.count = this.count / 2; this.time = this.time / RunnableListAuto.MIN_THREAD;
this.count = this.count / RunnableListAuto.MIN_THREAD;
} }
} }
......
...@@ -5,15 +5,20 @@ import com.yanzuoguang.util.log.Log; ...@@ -5,15 +5,20 @@ import com.yanzuoguang.util.log.Log;
/** /**
* 线程执行类 * 线程执行类
*
* @author 颜佐光 * @author 颜佐光
*/ */
public class ThreadNext { public class ThreadNext {
/**
* 下一个处理结接口
*/
public interface Next { public interface Next {
/** /**
* 执行下一个函数,出现异常会继续执行 * 执行下一个函数,出现异常会继续执行
* *
* @return 是否继续执行 * @return 是否继续执行
* @throws Exception 异常信息
*/ */
boolean next() throws Exception; boolean next() throws Exception;
......
package com.yanzuoguang.cloud;
/**
*
*/
public class CloudContans {
/**
* 日志模块
*/
public static final String LOG_MODULE = "log";
}
...@@ -5,6 +5,7 @@ import com.yanzuoguang.util.vo.ResponseResult; ...@@ -5,6 +5,7 @@ import com.yanzuoguang.util.vo.ResponseResult;
/** /**
* 调用外置服务保存日志对象 * 调用外置服务保存日志对象
*
* @author 颜佐光 * @author 颜佐光
*/ */
public interface LogFeign { public interface LogFeign {
...@@ -13,6 +14,7 @@ public interface LogFeign { ...@@ -13,6 +14,7 @@ public interface LogFeign {
* 保存日志对象 * 保存日志对象
* *
* @param log 需要保存的日志对象 * @param log 需要保存的日志对象
* @return 日志服务返回结果
*/ */
ResponseResult<String> save(LogVo log); ResponseResult<String> save(LogVo log);
} }
package com.yanzuoguang.cloud.aop; package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.cloud.CloudContans;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.StringHelper; import com.yanzuoguang.util.helper.StringHelper;
...@@ -77,7 +78,7 @@ public class MqAspect extends BaseRequestAspect { ...@@ -77,7 +78,7 @@ public class MqAspect extends BaseRequestAspect {
*/ */
private void saveInterLogs(ProceedingJoinPoint joinPoint, ResponseResult responseResult) { private void saveInterLogs(ProceedingJoinPoint joinPoint, ResponseResult responseResult) {
// 日志请求不记录,防止死循环递归 // 日志请求不记录,防止死循环递归
if (applicationName.indexOf("log") >= 0) { if (applicationName.indexOf(CloudContans.LOG_MODULE) >= 0) {
return; return;
} }
// 正常请求不记录 // 正常请求不记录
......
package com.yanzuoguang.cloud.aop; package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.cloud.CloudContans;
import com.yanzuoguang.util.base.ObjectHelper; import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
...@@ -146,7 +147,7 @@ public class WebAspect extends BaseRequestAspect { ...@@ -146,7 +147,7 @@ public class WebAspect extends BaseRequestAspect {
*/ */
private void saveInterLogs(ProceedingJoinPoint joinPoint, ResponseResult responseResult) { private void saveInterLogs(ProceedingJoinPoint joinPoint, ResponseResult responseResult) {
// 日志请求不记录,防止死循环递归 // 日志请求不记录,防止死循环递归
if (applicationName.indexOf("log") >= 0) { if (applicationName.indexOf(CloudContans.LOG_MODULE) >= 0) {
return; return;
} }
// 正常请求不记录 // 正常请求不记录
......
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
/** /**
* 基本服务接口 * 基本服务接口
*
* @author 颜佐光 * @author 颜佐光
*/ */
public interface BaseService<T> { public interface BaseService<T> {
...@@ -11,6 +12,7 @@ public interface BaseService<T> { ...@@ -11,6 +12,7 @@ public interface BaseService<T> {
* 创建数据 * 创建数据
* *
* @param models 需要创建的数据 * @param models 需要创建的数据
* @return 创建id集合
*/ */
List<String> create(T... models); List<String> create(T... models);
...@@ -18,6 +20,7 @@ public interface BaseService<T> { ...@@ -18,6 +20,7 @@ public interface BaseService<T> {
* 修改数据 * 修改数据
* *
* @param models 需要修改的数据 * @param models 需要修改的数据
* @return 创建id集合
*/ */
List<String> update(T... models); List<String> update(T... models);
...@@ -25,6 +28,7 @@ public interface BaseService<T> { ...@@ -25,6 +28,7 @@ public interface BaseService<T> {
* 保存数据 * 保存数据
* *
* @param models 需要保存的数据 * @param models 需要保存的数据
* @return 创建id集合
*/ */
List<String> save(T... models); List<String> save(T... models);
...@@ -32,6 +36,7 @@ public interface BaseService<T> { ...@@ -32,6 +36,7 @@ public interface BaseService<T> {
* 删除数据 * 删除数据
* *
* @param models 需要删除的数据 * @param models 需要删除的数据
* @return 创建id集合
*/ */
int remove(T... models); int remove(T... models);
...@@ -39,6 +44,7 @@ public interface BaseService<T> { ...@@ -39,6 +44,7 @@ public interface BaseService<T> {
* 加载数据 * 加载数据
* *
* @param models 需要删除的数据 * @param models 需要删除的数据
* @return 创建id集合
*/ */
List<T> load(T... models); List<T> load(T... models);
} }
...@@ -10,6 +10,7 @@ import java.util.List; ...@@ -10,6 +10,7 @@ import java.util.List;
/** /**
* 基本服务实现 * 基本服务实现
*
* @author 颜佐光 * @author 颜佐光
*/ */
public abstract class BaseServiceImpl<T> implements BaseService<T> { public abstract class BaseServiceImpl<T> implements BaseService<T> {
...@@ -35,9 +36,9 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> { ...@@ -35,9 +36,9 @@ public abstract class BaseServiceImpl<T> implements BaseService<T> {
/** /**
* @param * 获取Dao类来处理
* @return *
* @description 获取Dao类来处理 * @return Dao层操作类
*/ */
protected abstract BaseDao getDao(); protected abstract BaseDao getDao();
......
...@@ -7,6 +7,7 @@ import java.util.List; ...@@ -7,6 +7,7 @@ import java.util.List;
/** /**
* 发送消息服务 * 发送消息服务
*
* @author 颜佐光 * @author 颜佐光
*/ */
public interface MessageService { public interface MessageService {
...@@ -39,14 +40,16 @@ public interface MessageService { ...@@ -39,14 +40,16 @@ public interface MessageService {
/** /**
* 消息发送成功 * 消息发送成功
* *
* @param id * @param id 编号
* @return 成功后返回编号
*/ */
String onSuccess(String id); String onSuccess(String id);
/** /**
* 消息发送失败 * 消息发送失败
* *
* @param messageVo * @param messageVo 消息处理错误
* @return 成功后返回编号
*/ */
String onError(MessageVo messageVo); String onError(MessageVo messageVo);
} }
...@@ -10,13 +10,15 @@ import org.springframework.amqp.core.Message; ...@@ -10,13 +10,15 @@ import org.springframework.amqp.core.Message;
/** /**
* 消息队列服务 * 消息队列服务
*
* @author 颜佐光 * @author 颜佐光
*/ */
public interface MqService { public interface MqService {
/** /**
* 保存演示DEMO * 保存演示DEMO
* *
* @param req * @param req 需要发送的消息
* @return 创建队列
*/ */
String createQueue(QueueVo req); String createQueue(QueueVo req);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment