提交 309a3d2c 编写于 作者: zhouweidong's avatar zhouweidong

rocketMQ优化

上级 44816124
...@@ -18,6 +18,22 @@ TARGET=PSSYSTEM ...@@ -18,6 +18,22 @@ TARGET=PSSYSTEM
</#if> </#if>
</#list> </#list>
<#if hasMQProducer || hasMQConsumer> <#if hasMQProducer || hasMQConsumer>
<#comment>服务接口微服务平台配置</#comment>
<#assign mqServerAddress="">
<#if sys.getAllPSDevSlnMSDepAPIs()??>
<#list sys.getAllPSDevSlnMSDepAPIs() as depSysApi>
<#if depSysApi.getPSDCMSPlatform()?? >
<#if depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")??>
<#assign mqServerAddress = depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")>
</#if>
</#if>
</#list>
</#if>
<#if mqServerAddress!=''>
<#assign mqServer="on">
<#else>
<#assign mqServer="off">
</#if>
package ${pub.getPKGCodeName()}.core.util.config; package ${pub.getPKGCodeName()}.core.util.config;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -30,9 +46,11 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -30,9 +46,11 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@Slf4j @Slf4j
@Configuration @Configuration
@ConditionalOnExpression("${r'${ibiz.rocketmq.producer.isOnOff:\''+mqServer+'\'}.equals(\'on\')}'}
public class RocketMQConfig { public class RocketMQConfig {
<#if hasMQProducer> <#if hasMQProducer>
......
...@@ -13,6 +13,22 @@ TARGET=PSSYSTEM ...@@ -13,6 +13,22 @@ TARGET=PSSYSTEM
</#if> </#if>
</#list> </#list>
<#if hasMQConsumer> <#if hasMQConsumer>
<#comment>服务接口微服务平台配置</#comment>
<#assign mqServerAddress="">
<#if sys.getAllPSDevSlnMSDepAPIs()??>
<#list sys.getAllPSDevSlnMSDepAPIs() as depSysApi>
<#if depSysApi.getPSDCMSPlatform()?? >
<#if depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")??>
<#assign mqServerAddress = depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")>
</#if>
</#if>
</#list>
</#if>
<#if mqServerAddress!=''>
<#assign mqServer="on">
<#else>
<#assign mqServer="off">
</#if>
package ${pub.getPKGCodeName()}.core.util.config; package ${pub.getPKGCodeName()}.core.util.config;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,6 +36,7 @@ import com.alibaba.fastjson.JSON; ...@@ -20,6 +36,7 @@ import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus; import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly; import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
...@@ -32,6 +49,7 @@ import java.util.List; ...@@ -32,6 +49,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Component @Component
@ConditionalOnExpression("${r'${ibiz.rocketmq.producer.isOnOff:\''+mqServer+'\'}.equals(\'on\')}'}
public class RocketMQListenerProcessor implements MessageListenerOrderly { public class RocketMQListenerProcessor implements MessageListenerOrderly {
<#list sys.getAllPSDataEntities() as dataEntity> <#list sys.getAllPSDataEntities() as dataEntity>
......
...@@ -13,6 +13,22 @@ TARGET=PSSYSTEM ...@@ -13,6 +13,22 @@ TARGET=PSSYSTEM
</#if> </#if>
</#list> </#list>
<#if hasMQProducer> <#if hasMQProducer>
<#comment>服务接口微服务平台配置</#comment>
<#assign mqServerAddress="">
<#if sys.getAllPSDevSlnMSDepAPIs()??>
<#list sys.getAllPSDevSlnMSDepAPIs() as depSysApi>
<#if depSysApi.getPSDCMSPlatform()?? >
<#if depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")??>
<#assign mqServerAddress = depSysApi.getUserParam("ibiz.rocketmq.producer.namesrvAddr","")>
</#if>
</#if>
</#list>
</#if>
<#if mqServerAddress!=''>
<#assign mqServer="on">
<#else>
<#assign mqServer="off">
</#if>
package ${pub.getPKGCodeName()}.util.aspect; package ${pub.getPKGCodeName()}.util.aspect;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -32,6 +48,7 @@ import org.springframework.expression.Expression; ...@@ -32,6 +48,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser; import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -41,9 +58,10 @@ import java.util.List; ...@@ -41,9 +58,10 @@ import java.util.List;
/** /**
* rocketMQ消息切面 * rocketMQ消息切面
*/ */
@Slf4j
@Aspect @Aspect
@Component @Component
@Slf4j @ConditionalOnExpression("${r'${ibiz.rocketmq.producer.isOnOff:\''+mqServer+'\'}.equals(\'on\')}'}
public class RocketMQAspect public class RocketMQAspect
{ {
private final ExpressionParser parser = new SpelExpressionParser(); private final ExpressionParser parser = new SpelExpressionParser();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册