Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
e7772aa9
Commit
e7772aa9
authored
Nov 16, 2022
by
litengwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
任务 11836
parent
c66d7846
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
46 deletions
+68
-46
KafkaConsumerService.java
.../com/yeejoin/amos/message/kafka/KafkaConsumerService.java
+1
-1
KafkaConfig.java
...va/com/yeejoin/amos/message/kafka/config/KafkaConfig.java
+34
-34
application-dev.properties
...ils-message/src/main/resources/application-dev.properties
+11
-3
application-roma.properties
...ls-message/src/main/resources/application-roma.properties
+11
-3
topic.json
...mos-boot-utils-message/src/main/resources/json/topic.json
+11
-5
No files found.
amos-boot-utils/amos-boot-utils-message/src/main/java/com/yeejoin/amos/message/kafka/KafkaConsumerService.java
View file @
e7772aa9
...
@@ -28,7 +28,7 @@ public class KafkaConsumerService {
...
@@ -28,7 +28,7 @@ public class KafkaConsumerService {
* 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
* 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
* @param message 消息
* @param message 消息
*/
*/
@KafkaListener
(
id
=
"consumerSingle"
,
topics
=
"#{'${kafka.topics}'.split(',')}"
)
@KafkaListener
(
id
=
"consumerSingle"
,
topics
=
"#{'${kafka.topics}'.split(',')}"
,
errorHandler
=
"consumerAwareListenerErrorHandler"
)
public
void
consumerSingle
(
String
message
,
Acknowledgment
ack
)
{
public
void
consumerSingle
(
String
message
,
Acknowledgment
ack
)
{
JSONObject
messageObj
=
JSONObject
.
fromObject
(
message
);
JSONObject
messageObj
=
JSONObject
.
fromObject
(
message
);
String
topic
=
messageObj
.
getString
(
"topic"
);
String
topic
=
messageObj
.
getString
(
"topic"
);
...
...
amos-boot-utils/amos-boot-utils-message/src/main/java/com/yeejoin/amos/message/kafka/config/KafkaConfig.java
View file @
e7772aa9
package
com
.
yeejoin
.
amos
.
message
.
kafka
.
config
;
//package com.yeejoin.amos.message.kafka.config;
//
//
import
org.apache.kafka.clients.admin.NewTopic
;
//import org.apache.kafka.clients.admin.NewTopic;
import
org.springframework.beans.factory.annotation.Value
;
//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
java.util.Arrays
;
//import java.util.Arrays;
//
/**
///**
* topic初始化
// * topic初始化
*
// *
* @author litw
// * @author litw
* @create 2022/11/1 10:06
// * @create 2022/11/1 10:06
*/
// */
@Configuration
class
KafkaConfig
{
//@Configuration class KafkaConfig {
//
@Value
(
"${kafka.init.topics}"
)
// @Value("${kafka.init.topics}")
private
String
topics
;
// private String topics;
//
/**
// /**
* 创建一个名为topic.test的Topic并设置分区数为8,分区副本数为2
// * 创建一个名为topic.test的Topic并设置分区数为8,分区副本数为2
*/
// */
@Bean
public
void
initialTopic
()
{
// @Bean public void initialTopic() {
String
[]
split
=
topics
.
split
(
","
);
// String[] split = topics.split(",");
Arrays
.
stream
(
split
).
forEach
(
e
->{
// Arrays.stream(split).forEach(e->{
new
NewTopic
(
e
,
8
,
(
short
)
2
);
// new NewTopic(e, 8, (short) 2);
});
// });
}
// }
//
//
}
//}
\ No newline at end of file
\ No newline at end of file
amos-boot-utils/amos-boot-utils-message/src/main/resources/application-dev.properties
View file @
e7772aa9
...
@@ -78,9 +78,17 @@ emqx.client-password=public
...
@@ -78,9 +78,17 @@ emqx.client-password=public
emqx.max-inflight
=
1000
emqx.max-inflight
=
1000
# 下面个配置默认站端 中心级系统的时候注释掉上边 放开下边
#站端配置
#需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
#需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
kafka.topics
=
null.topic
kafka.topics
=
null.topic
kafka.init.topics
=
#需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
#需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
emq.topic
=
emq.iot.created,emq.patrol.created,emq.sign.created,emq.bussSign.created,emq.user.created
emq.topic
=
emq.xf.created,emq.iot.created,emq.patrol.created,emq.sign.created,emq.bussSign.created,emq.user.created
\ No newline at end of file
##中心级配置配置
##需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
#kafka.topics=JKXT2BP-XFYY-Topic
#
##需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
#
emq.topic
=
\ No newline at end of file
amos-boot-utils/amos-boot-utils-message/src/main/resources/application-roma.properties
View file @
e7772aa9
...
@@ -98,9 +98,17 @@ emqx.client-password=public
...
@@ -98,9 +98,17 @@ emqx.client-password=public
emqx.max-inflight
=
1000
emqx.max-inflight
=
1000
# 下面个配置默认站端 中心级系统的时候注释掉上边 放开下边
#站端配置
#需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
#需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
kafka.topics
=
null.topic
kafka.topics
=
null.topic
kafka.init.topics
=
#需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
#需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
emq.topic
=
emq.iot.created,emq.patrol.created,emq.sign.created,emq.bussSign.created,emq.user.created
emq.topic
=
emq.xf.created,emq.iot.created,emq.patrol.created,emq.sign.created,emq.bussSign.created,emq.user.created
\ No newline at end of file
##中心级配置配置
##需要监听得kafka消息主题 根据是否是中心极和站端选择需要监听得主题进行配置
#kafka.topics=JKXT2BP-XFYY-Topic
#
##需要监听得eqm消息主题 根据是否是中心极和站端选择需要监听得主题进行配置 emq.iot.created,
#
emq.topic
=
\ No newline at end of file
amos-boot-utils/amos-boot-utils-message/src/main/resources/json/topic.json
View file @
e7772aa9
...
@@ -2,26 +2,31 @@
...
@@ -2,26 +2,31 @@
{
{
"code"
:
"iot"
,
"code"
:
"iot"
,
"emqTopic"
:
"emq.iot.created"
,
"emqTopic"
:
"emq.iot.created"
,
"akkaTopic"
:
"
akka.iot.created
"
"akkaTopic"
:
"
JKXT2BP-XFYY-Topic
"
},
},
{
{
"code"
:
"patrol"
,
"code"
:
"patrol"
,
"emqTopic"
:
"emq.patrol.created"
,
"emqTopic"
:
"emq.patrol.created"
,
"akkaTopic"
:
"
akka.patrol.created
"
"akkaTopic"
:
"
JKXT2BP-XFYY-Topic
"
},
},
{
{
"code"
:
"sign"
,
"code"
:
"sign"
,
"emqTopic"
:
"emq.sign.created"
,
"emqTopic"
:
"emq.sign.created"
,
"akkaTopic"
:
"
akka.sign.created
"
"akkaTopic"
:
"
JKXT2BP-XFYY-Topic
"
},
},
{
{
"code"
:
"bussSign"
,
"code"
:
"bussSign"
,
"emqTopic"
:
"emq.bussSign.created"
,
"emqTopic"
:
"emq.bussSign.created"
,
"akkaTopic"
:
"
akka.bussSign.created
"
"akkaTopic"
:
"
JKXT2BP-XFYY-Topic
"
},
},
{
{
"code"
:
"user"
,
"code"
:
"user"
,
"emqTopic"
:
"emq.user.created"
,
"emqTopic"
:
"emq.user.created"
,
"akkaTopic"
:
"akka.user.created"
"akkaTopic"
:
"JKXT2BP-XFYY-Topic"
},
{
"code"
:
"xf"
,
"emqTopic"
:
"emq.xf.created"
,
"akkaTopic"
:
"JKXT2BP-XF-Topic"
}
}
]
]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment