Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
jinan
wj-datacenter-platform
Commits
876625de
Commit
876625de
authored
Jun 27, 2024
by
zhoushiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json转换
parent
0474913b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
ConsumerHandler.java
...main/java/net/wanji/datacenter/kafka/ConsumerHandler.java
+8
-2
No files found.
wj-datacenter-service/src/main/java/net/wanji/datacenter/kafka/ConsumerHandler.java
View file @
876625de
package
net
.
wanji
.
datacenter
.
kafka
;
package
net
.
wanji
.
datacenter
.
kafka
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.NonNull
;
import
lombok.NonNull
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -180,10 +182,14 @@ public class ConsumerHandler implements KafkaListenerErrorHandler {
...
@@ -180,10 +182,14 @@ public class ConsumerHandler implements KafkaListenerErrorHandler {
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
recordStr
=
String
.
valueOf
(
record
.
value
());
String
recordStr
=
String
.
valueOf
(
record
.
value
());
LineCongestion
dto
=
JacksonUtils
.
getInstance
().
readValue
(
recordStr
,
LineCongestion
.
class
);
//LineCongestion dto = JacksonUtils.getInstance().readValue(recordStr, LineCongestion.class);
String
redisElement
=
objectMapper
.
writeValueAsString
(
dto
);
//LineCongestion dto = JSONObject.parseObject(recordStr, LineCongestion.class);//objectMapper.readValue(element.toString(), LineCongestion.class);
String
redisElement
=
recordStr
;
//JSONObject.toJSONString(dto, SerializerFeature.WriteNonStringValueAsString); //objectMapper.writeValueAsString(dto);
String
redisKey
=
"line_congestion_sink"
;
String
redisKey
=
"line_congestion_sink"
;
log
.
info
(
"消费干线指标信息:{}"
,
redisElement
);
redisUtils
.
addToSortedSetWithExpiry
(
redisKey
,
redisElement
,
TTL_IN_MILLIS
);
redisUtils
.
addToSortedSetWithExpiry
(
redisKey
,
redisElement
,
TTL_IN_MILLIS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Kafka收到路口事件数据异常"
,
e
);
log
.
error
(
"Kafka收到路口事件数据异常"
,
e
);
...
...
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