Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_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
赵啸非
smart_gov_platform
Commits
364550b6
Commit
364550b6
authored
Aug 18, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改网关日志
parent
dc1d564c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
82 deletions
+6
-82
smart-gateway/pom.xml
smart-gateway/pom.xml
+2
-2
smart-gateway/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
...a/com/mortals/xhx/base/framework/config/RabbitConfig.java
+0
-78
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
...tals/xhx/base/framework/filter/GatewayResponseFilter.java
+1
-1
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalLogFilter.java
...om/mortals/xhx/base/framework/filter/GlobalLogFilter.java
+1
-0
smart-gateway/src/main/java/com/mortals/xhx/base/framework/service/MessageProducer.java
...m/mortals/xhx/base/framework/service/MessageProducer.java
+2
-1
No files found.
smart-gateway/pom.xml
View file @
364550b6
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>
/
test
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost>
/
</profiles.rabbitmq.virtualhost>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>
/
test
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost>
/
</profiles.rabbitmq.virtualhost>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.server-addr>
192.168.0.252:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
<profiles.nacos.namespace>
smart-gov
</profiles.nacos.namespace>
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
View file @
364550b6
package
com.mortals.xhx.base.framework.config
;
package
com.mortals.xhx.base.framework.config
;
import
com.mortals.xhx.common.key.QueueKey
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.amqp.core.DirectExchange
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
...
@@ -15,81 +10,8 @@ import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainer
...
@@ -15,81 +10,8 @@ import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainer
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.HashMap
;
import
java.util.Map
;
@Configuration
@Configuration
public
class
RabbitConfig
{
public
class
RabbitConfig
{
public
Integer
messageTtl
=
86400000
;
public
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
// 创建 Queue
@Bean
public
Queue
accessLogQueue
()
{
args
.
put
(
"x-message-ttl"
,
messageTtl
);
return
new
Queue
(
QueueKey
.
ACCESS_LOG_QUEUE
,
// Queue 名字
true
,
// durable: 是否持久化
false
,
// exclusive: 是否排它
false
,
args
);
// autoDelete: 是否自动删除
}
@Bean
public
Queue
bizLogQueue
()
{
args
.
put
(
"x-message-ttl"
,
messageTtl
);
return
new
Queue
(
QueueKey
.
BIZ_LOG_QUEUE
,
// Queue 名字
true
,
// durable: 是否持久化
false
,
// exclusive: 是否排它
false
,
args
);
// autoDelete: 是否自动删除
}
@Bean
public
Queue
errorLogQueue
()
{
return
new
Queue
(
QueueKey
.
ERROR_LOG_QUEUE
,
// Queue 名字
true
,
// durable: 是否持久化
false
,
// exclusive: 是否排它
false
,
args
);
// autoDelete: 是否自动删除
}
@Bean
public
Queue
operationLogQueue
()
{
return
new
Queue
(
QueueKey
.
OPERATION_LOG_QUEUE
,
// Queue 名字
true
,
// durable: 是否持久化
false
,
// exclusive: 是否排它
false
,
args
);
// autoDelete: 是否自动删除
}
// 创建 Direct Exchange
@Bean
public
DirectExchange
exchange
()
{
return
new
DirectExchange
(
QueueKey
.
EXCHANGE
,
true
,
// durable: 是否持久化
false
);
// exclusive: 是否排它
}
// 创建 Binding
@Bean
public
Binding
accessBinding
()
{
return
BindingBuilder
.
bind
(
accessLogQueue
()).
to
(
exchange
()).
with
(
QueueKey
.
ACCESS_LOG_QUEUE
);
}
@Bean
public
Binding
bizBinding
()
{
return
BindingBuilder
.
bind
(
bizLogQueue
()).
to
(
exchange
()).
with
(
QueueKey
.
BIZ_LOG_QUEUE
);
}
@Bean
public
Binding
errorBinding
()
{
return
BindingBuilder
.
bind
(
errorLogQueue
()).
to
(
exchange
()).
with
(
QueueKey
.
ERROR_LOG_QUEUE
);
}
@Bean
public
Binding
operBinding
()
{
return
BindingBuilder
.
bind
(
operationLogQueue
()).
to
(
exchange
()).
with
(
QueueKey
.
OPERATION_LOG_QUEUE
);
}
@Bean
(
name
=
"consumerBatchContainerFactory"
)
@Bean
(
name
=
"consumerBatchContainerFactory"
)
public
SimpleRabbitListenerContainerFactory
consumerBatchContainerFactory
(
public
SimpleRabbitListenerContainerFactory
consumerBatchContainerFactory
(
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GatewayResponseFilter.java
View file @
364550b6
...
@@ -35,7 +35,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.O
...
@@ -35,7 +35,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.O
* @date: 2022/8/18 13:48
* @date: 2022/8/18 13:48
* @description:
* @description:
**/
**/
//
@Component
@Component
@Slf4j
@Slf4j
public
class
GatewayResponseFilter
implements
GlobalFilter
,
Ordered
{
public
class
GatewayResponseFilter
implements
GlobalFilter
,
Ordered
{
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/filter/GlobalLogFilter.java
View file @
364550b6
...
@@ -96,6 +96,7 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
...
@@ -96,6 +96,7 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
accessLogPdu
.
setRequestParam
(
paramStr
);
accessLogPdu
.
setRequestParam
(
paramStr
);
accessLogPdu
.
setLogTime
(
new
Date
());
accessLogPdu
.
setLogTime
(
new
Date
());
accessLogPdu
.
setMethod
(
method
);
accessLogPdu
.
setMethod
(
method
);
accessLogPdu
.
setUri
(
path
);
messageProducer
.
syncAccessSend
(
accessLogPdu
);
messageProducer
.
syncAccessSend
(
accessLogPdu
);
exchange
.
getAttributes
().
put
(
START_TIME
,
System
.
currentTimeMillis
());
exchange
.
getAttributes
().
put
(
START_TIME
,
System
.
currentTimeMillis
());
...
...
smart-gateway/src/main/java/com/mortals/xhx/base/framework/service/MessageProducer.java
View file @
364550b6
package
com.mortals.xhx.base.framework.service
;
package
com.mortals.xhx.base.framework.service
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.pdu.access.AccessLogPdu
;
import
com.mortals.xhx.common.pdu.access.AccessLogPdu
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
...
@@ -13,7 +14,7 @@ public class MessageProducer {
...
@@ -13,7 +14,7 @@ public class MessageProducer {
private
RabbitTemplate
rabbitTemplate
;
private
RabbitTemplate
rabbitTemplate
;
public
void
syncAccessSend
(
AccessLogPdu
accessLogPdu
)
{
public
void
syncAccessSend
(
AccessLogPdu
accessLogPdu
)
{
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
BIZ_LOG_QUEUE
,
accessLogPdu
);
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ACCESS_LOG_QUEUE
,
JSON
.
toJSONString
(
accessLogPdu
)
);
}
}
}
}
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