Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
log-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
log-platform
Commits
3c35e37e
Commit
3c35e37e
authored
Aug 26, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常日志前端展示添加
parent
a7a7732f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
...ase/framework/listener/AccessMessageConsumerListener.java
+21
-18
No files found.
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
View file @
3c35e37e
...
...
@@ -24,10 +24,7 @@ import org.springframework.messaging.handler.annotation.Payload;
import
org.springframework.stereotype.Component
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -47,34 +44,40 @@ public class AccessMessageConsumerListener {
private
AccessLogService
accessLogService
;
@RabbitHandler
public
void
onMessage
(
@Payload
List
<
String
>
messages
,
Channel
channel
)
throws
Exception
{
log
.
info
(
"[Access onMessage][线程编号:{} 消息数量:{}]"
,
Thread
.
currentThread
().
getName
()+
Thread
.
currentThread
().
getId
(),
messages
.
size
());
public
void
onMessage
(
@Payload
List
<
String
>
messages
)
throws
Exception
{
log
.
info
(
"[Access onMessage][线程编号:{} 消息数量:{}]"
,
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getId
(),
messages
.
size
());
// if(messages instanceof ArrayList<String>){
//
// }
if
(
messages
instanceof
List
&&
((
List
)
messages
).
stream
()
.
noneMatch
((
o
->
!(
o
instanceof
String
))))
{
log
.
info
(
"1111111111"
);
}
else
{
log
.
info
(
"2222222222222"
);
}
// messages.forEach(entity -> {
// entity.setId(IdUtil.getSnowflake(0, 1).nextId());
// entity.setCreateUserId(1L);
// entity.setCreateTime(new Date());
// });
// accessLogService.save(messages);
List
<
AccessLogEntity
>
collect
=
messages
.
stream
().
map
(
message
->
{
try
{
//String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8));
log
.
info
(
"message:{}"
,
message
);
log
.
info
(
"message:{}"
,
message
);
AccessLogEntity
entity
=
JSON
.
parseObject
(
message
,
AccessLogEntity
.
class
);
entity
.
setId
(
IdUtil
.
getSnowflake
(
0
,
1
).
nextId
());
entity
.
setCreateUserId
(
1L
);
entity
.
setCreateTime
(
new
Date
());
return
entity
;
}
catch
(
Exception
e
)
{
log
.
info
(
"反序列化异常"
,
e
);
}
catch
(
Exception
e
)
{
log
.
info
(
"反序列化异常"
,
e
);
return
null
;
}
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
// collect.forEach(accessLogEntity -> accessLogService.save(accessLogEntity));
accessLogService
.
save
(
collect
);
}
...
...
@@ -82,7 +85,7 @@ public class AccessMessageConsumerListener {
public
static
void
main
(
String
[]
args
)
{
String
json
=
"{\n"
+
String
json
=
"{\n"
+
" \"appName\":\"smart-gateway\",\n"
+
" \"deleted\":0,\n"
+
" \"duration\":12,\n"
+
...
...
@@ -115,7 +118,7 @@ public class AccessMessageConsumerListener {
System
.
out
.
println
(
JSON
.
toJSONString
(
accessLogEntity
));
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"111"
,
json
);
jsonObject
.
put
(
"111"
,
json
);
System
.
out
.
println
(
JSON
.
toJSONString
(
jsonObject
));
...
...
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