Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
3630bef7
提交
3630bef7
编写于
11月 23, 2022
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
换装rocketmq template
上级
b072597e
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
115 行增加
和
4 行删除
+115
-4
pom.xml
ibzdst-core/pom.xml
+2
-2
ResultMQMsgListener.java
...ain/java/cn/ibizlab/core/message/ResultMQMsgListener.java
+51
-0
RuleEngineMQMsgListener.java
...java/cn/ibizlab/core/message/RuleEngineMQMsgListener.java
+60
-0
MQConsumerConfigure.java
...java/cn/ibizlab/core/util/config/MQConsumerConfigure.java
+2
-2
未找到文件。
ibzdst-core/pom.xml
浏览文件 @
3630bef7
...
...
@@ -108,8 +108,8 @@
<!-- rocketmq -->
<dependency>
<groupId>
org.apache.rocketmq
</groupId>
<artifactId>
rocketmq-
client
</artifactId>
<version>
4.7
.0
</version>
<artifactId>
rocketmq-
spring-boot-starter
</artifactId>
<version>
2.2
.0
</version>
</dependency>
<!--达梦数据库-->
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/message/ResultMQMsgListener.java
0 → 100644
浏览文件 @
3630bef7
package
cn
.
ibizlab
.
core
.
message
;
import
cn.ibizlab.core.extensions.cql.ExecResultRepository
;
import
cn.ibizlab.core.extensions.domain.ResultsMQMsg
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.spring.annotation.ConsumeMode
;
import
org.apache.rocketmq.spring.annotation.RocketMQMessageListener
;
import
org.apache.rocketmq.spring.core.RocketMQListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
@Slf4j
@Component
@ConditionalOnExpression
(
"'${rocketmq.consumer.namesrvAddr:}'!='' && ${rocketmq.consumer.enabled:false}"
)
@RocketMQMessageListener
(
nameServer
=
"${rocketmq.consumer.namesrvAddr:}"
,
topic
=
"${rocketmq.producer.resultsTopic:DSTRESULTSMSG}"
,
selectorExpression
=
"*"
,
consumerGroup
=
"${rocketmq.consumer.resultsGroupName:resultsCG}"
,
consumeThreadMax
=
20
,
consumeMode
=
ConsumeMode
.
CONCURRENTLY
)
public
class
ResultMQMsgListener
implements
RocketMQListener
<
MessageExt
>
{
@Autowired
(
required
=
false
)
@Lazy
private
ExecResultRepository
execResultRepository
;
@Override
public
void
onMessage
(
MessageExt
messageExt
)
{
try
{
log
.
info
(
"MQ消息topic={}, tags={}, 消息内容={}"
,
messageExt
.
getTopic
(),
messageExt
.
getTags
(),
messageExt
.
getMsgId
());
String
body
=
new
String
(
messageExt
.
getBody
(),
"utf-8"
);
String
tags
=
messageExt
.
getTags
();
ResultsMQMsg
resultsMQMsg
=
JSON
.
parseObject
(
body
,
new
TypeReference
<
ResultsMQMsg
>()
{});
if
(!
StringUtils
.
isEmpty
(
resultsMQMsg
.
getKeyValueField
()))
execResultRepository
.
saveResultsMQMsg
(
resultsMQMsg
);
}
catch
(
Exception
e
)
{
log
.
error
(
"获取MQ消息内容异常{}"
,
e
);
}
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/message/RuleEngineMQMsgListener.java
0 → 100644
浏览文件 @
3630bef7
package
cn
.
ibizlab
.
core
.
message
;
import
cn.ibizlab.core.extensions.domain.EngineMQMsg
;
import
cn.ibizlab.core.extensions.service.DABuildExService
;
import
cn.ibizlab.core.extensions.service.RuleEngineExService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.spring.annotation.ConsumeMode
;
import
org.apache.rocketmq.spring.annotation.RocketMQMessageListener
;
import
org.apache.rocketmq.spring.core.RocketMQListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Component
;
@Slf4j
@Component
@ConditionalOnExpression
(
"'${rocketmq.consumer.namesrvAddr:}'!='' && ${rocketmq.consumer.enabled:false}"
)
@RocketMQMessageListener
(
nameServer
=
"${rocketmq.consumer.namesrvAddr:}"
,
topic
=
"${rocketmq.producer.ruleEngineTopic:DSTMSG}"
,
selectorExpression
=
"*"
,
consumerGroup
=
"${rocketmq.consumer.ruleEngineGroupName:dstCG}"
,
consumeThreadMax
=
1
,
consumeMode
=
ConsumeMode
.
ORDERLY
)
public
class
RuleEngineMQMsgListener
implements
RocketMQListener
<
MessageExt
>
{
@Autowired
@Lazy
private
RuleEngineExService
ruleEngineExService
;
@Autowired
@Lazy
private
DABuildExService
daBuildExService
;
@Override
public
void
onMessage
(
MessageExt
messageExt
)
{
try
{
log
.
info
(
"MQ消息topic={}, tags={}, 消息内容={}"
,
messageExt
.
getTopic
(),
messageExt
.
getTags
(),
messageExt
.
getMsgId
());
String
body
=
new
String
(
messageExt
.
getBody
(),
"utf-8"
);
String
tags
=
messageExt
.
getTags
();
EngineMQMsg
engineMQMsg
=
JSON
.
parseObject
(
body
,
new
TypeReference
<
EngineMQMsg
>()
{});
System
.
out
.
println
(
engineMQMsg
.
toString
());
if
(
"Engine"
.
equalsIgnoreCase
(
tags
))
{
ruleEngineExService
.
processData
(
engineMQMsg
);
}
else
if
(
"Build"
.
equalsIgnoreCase
(
tags
)){
daBuildExService
.
processData
(
engineMQMsg
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取MQ消息内容异常{}"
,
e
);
}
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/util/config/MQConsumerConfigure.java
浏览文件 @
3630bef7
...
...
@@ -16,8 +16,8 @@ import org.springframework.context.annotation.Configuration;
* mq消费者配置
*/
@Slf4j
@Configuration
@ConditionalOnExpression
(
"'${rocketmq.consumer.namesrvAddr:}'!=''"
)
//
@Configuration
//
@ConditionalOnExpression("'${rocketmq.consumer.namesrvAddr:}'!=''")
public
class
MQConsumerConfigure
{
@Value
(
"${rocketmq.consumer.ruleEngineGroupName:dstCG}"
)
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录