Commit 0031b938 authored by yanzg's avatar yanzg

修改实例化关系

parent 446dce4e
package com.yanzuoguang.cloud.aop; package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.mq.plan.YzgMqConsumer; import com.yanzuoguang.mq.plan.YzgMqConsumer;
import com.yanzuoguang.mq.service.MessageLogService;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.vo.LogVo; import com.yanzuoguang.util.vo.LogVo;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -10,6 +11,7 @@ import org.aspectj.lang.annotation.Pointcut; ...@@ -10,6 +11,7 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -26,6 +28,9 @@ public class MqAspect extends BaseRequestAspect { ...@@ -26,6 +28,9 @@ public class MqAspect extends BaseRequestAspect {
private static final String TAG = MqAspect.class.getSimpleName(); private static final String TAG = MqAspect.class.getSimpleName();
@Autowired
private MessageLogService logService;
/** /**
* exec aop point aspect * exec aop point aspect
*/ */
...@@ -63,6 +68,7 @@ public class MqAspect extends BaseRequestAspect { ...@@ -63,6 +68,7 @@ public class MqAspect extends BaseRequestAspect {
ex = e; ex = e;
throw e; throw e;
} finally { } finally {
logService.logCurrentRemove();
responseLog(declaringType, TAG, url, clear, start, getRequestBody(joinPoint), result, ex, log); responseLog(declaringType, TAG, url, clear, start, getRequestBody(joinPoint), result, ex, log);
} }
} }
...@@ -74,19 +80,17 @@ public class MqAspect extends BaseRequestAspect { ...@@ -74,19 +80,17 @@ public class MqAspect extends BaseRequestAspect {
} }
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method targetMethod = methodSignature.getMethod(); Method targetMethod = methodSignature.getMethod();
Message message = getMessage(joinPoint.getArgs());
if (message != null) {
logService.logCurrent(message);
}
if (YzgMqConsumer.class.equals(targetMethod.getDeclaringClass())) { if (YzgMqConsumer.class.equals(targetMethod.getDeclaringClass())) {
ret = false; ret = false;
} else { } else {
RabbitListener annotation = targetMethod.getAnnotation(RabbitListener.class); RabbitListener annotation = targetMethod.getAnnotation(RabbitListener.class);
if (annotation != null) { if (annotation != null || message != null) {
ret = true; ret = true;
} }
if (!ret) {
Message message = getMessage(joinPoint.getArgs());
if (message != null) {
ret = true;
}
}
} }
return ret; return ret;
} }
......
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