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
3ebd3776
Commit
3ebd3776
authored
Aug 26, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常日志前端展示添加
parent
e7f2c60a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
20 deletions
+12
-20
log-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
...a/com/mortals/xhx/base/framework/config/RabbitConfig.java
+6
-0
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
...ase/framework/listener/AccessMessageConsumerListener.java
+6
-20
No files found.
log-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
View file @
3ebd3776
...
@@ -96,6 +96,12 @@ public class RabbitConfig {
...
@@ -96,6 +96,12 @@ public class RabbitConfig {
SimpleRabbitListenerContainerFactoryConfigurer
configurer
,
ConnectionFactory
connectionFactory
)
{
SimpleRabbitListenerContainerFactoryConfigurer
configurer
,
ConnectionFactory
connectionFactory
)
{
// 创建 SimpleRabbitListenerContainerFactory 对象
// 创建 SimpleRabbitListenerContainerFactory 对象
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
factory
.
setAfterReceivePostProcessors
(
m
->
{
m
.
getMessageProperties
().
setContentType
(
"application/json"
);
return
m
;
});
configurer
.
configure
(
factory
,
connectionFactory
);
configurer
.
configure
(
factory
,
connectionFactory
);
// 额外添加批量消费的属性
// 额外添加批量消费的属性
factory
.
setBatchListener
(
true
);
factory
.
setBatchListener
(
true
);
...
...
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
View file @
3ebd3776
...
@@ -37,15 +37,15 @@ import java.util.stream.Collectors;
...
@@ -37,15 +37,15 @@ import java.util.stream.Collectors;
**/
**/
@Slf4j
@Slf4j
@Component
@Component
//
@RabbitListener(queues = QueueKey.ACCESS_LOG_QUEUE,
@RabbitListener
(
queues
=
QueueKey
.
ACCESS_LOG_QUEUE
,
//
containerFactory = "consumerBatchContainerFactory")
containerFactory
=
"consumerBatchContainerFactory"
)
@RabbitListener
(
queues
=
QueueKey
.
ACCESS_LOG_QUEUE
)
//
@RabbitListener(queues = QueueKey.ACCESS_LOG_QUEUE)
public
class
AccessMessageConsumerListener
{
public
class
AccessMessageConsumerListener
{
@Autowired
@Autowired
private
AccessLogService
accessLogService
;
private
AccessLogService
accessLogService
;
@RabbitHandler
//
@RabbitHandler
public
void
onMessage
(
AccessLogEntity
entity
)
throws
Exception
{
public
void
onMessage
(
AccessLogEntity
entity
)
throws
Exception
{
log
.
info
(
"[Access onMessage single]"
);
log
.
info
(
"[Access onMessage single]"
);
...
@@ -55,34 +55,20 @@ public class AccessMessageConsumerListener {
...
@@ -55,34 +55,20 @@ public class AccessMessageConsumerListener {
accessLogService
.
save
(
entity
,
null
);
accessLogService
.
save
(
entity
,
null
);
}
}
//
@RabbitHandler
@RabbitHandler
public
void
onMessage
(
@Payload
List
<
String
>
messages
)
throws
Exception
{
public
void
onMessage
(
@Payload
List
<
String
>
messages
)
throws
Exception
{
log
.
info
(
"[Access onMessage][线程编号:{} 消息数量:{}]"
,
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getId
(),
messages
.
size
());
log
.
info
(
"[Access onMessage][线程编号:{} 消息数量:{}]"
,
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getId
(),
messages
.
size
());
// if(messages instanceof ArrayList<String>){
//
// }
if
(
messages
.
stream
().
noneMatch
((
o
->
!(
o
instanceof
String
))))
{
log
.
info
(
"都匹配"
);
}
else
{
log
.
info
(
"存在类型不匹配"
);
}
List
<
AccessLogEntity
>
collect
=
messages
.
stream
().
map
(
message
->
{
List
<
AccessLogEntity
>
collect
=
messages
.
stream
().
map
(
message
->
{
try
{
try
{
AccessLogEntity
entity
=
null
;
AccessLogEntity
entity
=
null
;
if
(
message
instanceof
String
){
log
.
info
(
"message:{}"
,
message
);
log
.
info
(
"message:{}"
,
message
);
entity
=
JSON
.
parseObject
(
message
,
AccessLogEntity
.
class
);
entity
=
JSON
.
parseObject
(
message
,
AccessLogEntity
.
class
);
entity
.
setId
(
IdUtil
.
getSnowflake
(
0
,
1
).
nextId
());
entity
.
setId
(
IdUtil
.
getSnowflake
(
0
,
1
).
nextId
());
entity
.
setCreateUserId
(
1L
);
entity
.
setCreateUserId
(
1L
);
entity
.
setCreateTime
(
new
Date
());
entity
.
setCreateTime
(
new
Date
());
}
else
{
// entity=(AccessLogEntity)message;
}
//String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8));
//String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8));
...
...
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