Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
ZHHT-IRN-BD-ANALYSIS
Project
Overview
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
李凯旋
ZHHT-IRN-BD-ANALYSIS
Commits
8ff4859c
Commit
8ff4859c
authored
Nov 16, 2022
by
吴延飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接入kafka数据流需要增加groupID参数
parent
5e8e5f6a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
FlinkUtils.java
...treaming/src/main/java/com/zhht/irn/utils/FlinkUtils.java
+8
-1
kafka.properties
...me/hologram-streaming/src/main/resources/kafka.properties
+2
-0
No files found.
realtime/hologram-streaming/src/main/java/com/zhht/irn/utils/FlinkUtils.java
View file @
8ff4859c
...
@@ -48,8 +48,13 @@ public class FlinkUtils {
...
@@ -48,8 +48,13 @@ public class FlinkUtils {
public
static
DataStream
<
String
>
createKafkaStream
(
String
[]
args
,
StreamExecutionEnvironment
environment
,
String
topic
,
String
offset
)
{
public
static
DataStream
<
String
>
createKafkaStream
(
String
[]
args
,
StreamExecutionEnvironment
environment
,
String
topic
,
String
offset
)
{
ParameterTool
kafkaTool
=
initParameterToolByArgs
(
args
);
ParameterTool
kafkaTool
=
initParameterToolByArgs
(
args
);
String
groupId
=
kafkaTool
.
get
(
"group.id"
,
"test"
);
return
createKafkaStream
(
args
,
environment
,
topic
,
groupId
,
offset
);
}
public
static
DataStream
<
String
>
createKafkaStream
(
String
[]
args
,
StreamExecutionEnvironment
environment
,
String
topic
,
String
groupId
,
String
offset
)
{
ParameterTool
kafkaTool
=
initParameterToolByArgs
(
args
);
// 加载Kafka信息 { topic 相关 }
// 加载Kafka信息 { topic 相关 }
String
groupId
=
kafkaTool
.
get
(
"group.id"
,
"group-wuyanfei"
);
String
servers
=
kafkaTool
.
getRequired
(
"bootstrap.servers"
);
String
servers
=
kafkaTool
.
getRequired
(
"bootstrap.servers"
);
List
<
String
>
topics
=
Arrays
.
asList
(
topic
.
split
(
","
));
List
<
String
>
topics
=
Arrays
.
asList
(
topic
.
split
(
","
));
String
autoCommit
=
kafkaTool
.
get
(
"enable.auto.commit"
,
"false"
);
String
autoCommit
=
kafkaTool
.
get
(
"enable.auto.commit"
,
"false"
);
...
@@ -75,6 +80,8 @@ public class FlinkUtils {
...
@@ -75,6 +80,8 @@ public class FlinkUtils {
return
rawStringStream
;
return
rawStringStream
;
}
}
private
static
ParameterTool
initParameterToolByArgs
(
String
[]
args
)
{
private
static
ParameterTool
initParameterToolByArgs
(
String
[]
args
)
{
// 获取Kafka配置文件
// 获取Kafka配置文件
ParameterTool
finkArgs
=
ParameterTool
.
fromArgs
(
args
);
ParameterTool
finkArgs
=
ParameterTool
.
fromArgs
(
args
);
...
...
realtime/hologram-streaming/src/main/resources/kafka.properties
View file @
8ff4859c
bootstrap.servers
=
10.100.32.173:9092
bootstrap.servers
=
10.100.32.173:9092
kafka.input.topics
=
trips_info
kafka.input.topics
=
trips_info
auto.offset.reset
=
earliest
auto.offset.reset
=
earliest
group.id
=
test
\ 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