提交 14e1f4b1 编写于 作者: zhouweidong's avatar zhouweidong

适配rocketmq

上级 96d71e84
......@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.List;
@Slf4j
......@@ -77,13 +78,13 @@ public class RocketMQConfig {
<#assign instanceName=syncAgent.getAgentTag2()>
</#if>
@Autowired
@Lazy
${pub.getPKGCodeName()}.core.${dataEntity.getPSSystemModule().getCodeName()?lower_case}.service.I${entityName}Service ${entityName}Service;
@Bean("${consumer}")
public DefaultMQPushConsumer ${srfmethodname(consumer)}(){
DefaultMQPushConsumer consumer = null;
try {
log.info("消息消费者");
consumer = new DefaultMQPushConsumer();
consumer.setNamesrvAddr("${nameAddress}");
consumer.setInstanceName("${instanceName}");
......
......@@ -17,16 +17,15 @@ package ${pub.getPKGCodeName()}.util.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.domain.EntityBase;
import ${pub.getPKGCodeName()}.util.errors.BadRequestAlertException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
......@@ -55,13 +54,15 @@ public class RocketMQAspect
<#assign producer=dataEntity.codeName+syncAgent.codeName+"producer">
@Autowired
@Qualifier("${producer}")
@Lazy
DefaultMQProducer ${producer};
@AfterReturning(value = "(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.remove*(..))) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.remove*(..))")
@Async
public void ${srfmethodname(producer)}(JoinPoint point){
<#if dataSync.getOutTestPSDEAction?? && dataSync.getOutTestPSDEAction()??>
outputAction(point,"${dataSync.getOutTestPSDEAction().codeName}");
<#assign actionName=srfmethodname(dataSync.getOutTestPSDEAction().codeName)>
outputAction(point,"${actionName}");
</#if>
sendMsg(${producer},"${dataSync.codeName}","${dataSync.codeName}",getEntity(point));
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册