Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample-form-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
赵啸非
sample-form-platform
Commits
943ca3d5
Commit
943ca3d5
authored
Jun 19, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加材料排序
parent
a4961482
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
1 deletion
+123
-1
common-lib/pom.xml
common-lib/pom.xml
+4
-1
common-lib/src/main/java/com/mortals/xhx/common/keys/QueueKey.java
...b/src/main/java/com/mortals/xhx/common/keys/QueueKey.java
+25
-0
common-lib/src/main/java/com/mortals/xhx/system/MessageProducer.java
...src/main/java/com/mortals/xhx/system/MessageProducer.java
+47
-0
common-lib/src/main/java/com/mortals/xhx/system/RabbitConfig.java
...ib/src/main/java/com/mortals/xhx/system/RabbitConfig.java
+41
-0
sample-form-manager/src/main/resources/bootstrap.yml
sample-form-manager/src/main/resources/bootstrap.yml
+6
-0
No files found.
common-lib/pom.xml
View file @
943ca3d5
...
@@ -53,7 +53,10 @@
...
@@ -53,7 +53,10 @@
<artifactId>
guava
</artifactId>
<artifactId>
guava
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
...
...
common-lib/src/main/java/com/mortals/xhx/common/keys/QueueKey.java
0 → 100644
View file @
943ca3d5
package
com.mortals.xhx.common.keys
;
/**
* rabbit 队列key定义
*/
public
class
QueueKey
{
public
static
final
String
ACCESS_LOG_QUEUE
=
"ACCESS_LOG_QUEUE"
;
public
static
final
String
BIZ_LOG_QUEUE
=
"BIZ_LOG_QUEUE"
;
public
static
final
String
ERROR_LOG_QUEUE
=
"ERROR_LOG_QUEUE"
;
public
static
final
String
OPERATION_LOG_QUEUE
=
"OPERATION_LOG_QUEUE"
;
public
static
final
String
EXCHANGE
=
"LOG"
;
public
static
final
String
ROUTING_KEY
=
"LOG_ROUTING_KEY"
;
}
common-lib/src/main/java/com/mortals/xhx/system/MessageProducer.java
0 → 100644
View file @
943ca3d5
package
com.mortals.xhx.system
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.model.AccessLogPdu
;
import
com.mortals.framework.model.BizLogPdu
;
import
com.mortals.framework.model.ErrorLogPdu
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.xhx.common.keys.QueueKey
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
@Component
@Primary
@Slf4j
public
class
MessageProducer
implements
IMessageProduceService
{
@Autowired
private
RabbitTemplate
rabbitTemplate
;
public
void
syncAccessSend
(
AccessLogPdu
accessLogPdu
)
{
//new Message(JSON.toJSONString(accessLogPdu).getBytes(StandardCharsets.UTF_8))
//rabbitTemplate.send(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE,new Message(JSON.toJSONString(accessLogPdu).getBytes(StandardCharsets.UTF_8)));
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ACCESS_LOG_QUEUE
,
JSON
.
toJSONString
(
accessLogPdu
));
//rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE, accessLogPdu);
}
@Override
public
void
syncBizSend
(
BizLogPdu
bizLogPdu
)
{
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
BIZ_LOG_QUEUE
,
JSON
.
toJSONString
(
bizLogPdu
));
}
@Override
public
void
syncErrorSend
(
ErrorLogPdu
errorLogPdu
)
{
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ERROR_LOG_QUEUE
,
JSON
.
toJSONString
(
errorLogPdu
));
}
@Override
public
void
syncOperSend
(
OperateLogPdu
operLogPdu
)
{
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
OPERATION_LOG_QUEUE
,
JSON
.
toJSONString
(
operLogPdu
));
}
}
common-lib/src/main/java/com/mortals/xhx/system/RabbitConfig.java
0 → 100644
View file @
943ca3d5
package
com.mortals.xhx.system
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
RabbitConfig
{
//@Bean(name = "consumerBatchContainerFactory")
public
SimpleRabbitListenerContainerFactory
consumerBatchContainerFactory
(
SimpleRabbitListenerContainerFactoryConfigurer
configurer
,
ConnectionFactory
connectionFactory
)
{
// 创建 SimpleRabbitListenerContainerFactory 对象
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
configurer
.
configure
(
factory
,
connectionFactory
);
// 额外添加批量消费的属性
factory
.
setBatchListener
(
true
);
factory
.
setBatchSize
(
10
);
factory
.
setReceiveTimeout
(
30
*
1000L
);
factory
.
setConsumerBatchEnabled
(
true
);
return
factory
;
}
//修改系列和与反序列化转换器
// @Bean
// public MessageConverter messageConverter() {
// return new Jackson2JsonMessageConverter();
// }
//@Bean
public
AsyncRabbitTemplate
asyncRabbitTemplate
(
RabbitTemplate
rabbitTemplate
)
{
AsyncRabbitTemplate
asyncRabbitTemplate
=
new
AsyncRabbitTemplate
(
rabbitTemplate
);
asyncRabbitTemplate
.
setReceiveTimeout
(
10000
);
return
asyncRabbitTemplate
;
}
}
sample-form-manager/src/main/resources/bootstrap.yml
View file @
943ca3d5
...
@@ -16,6 +16,12 @@ spring:
...
@@ -16,6 +16,12 @@ spring:
jackson
:
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
date-format
:
yyyy-MM-dd HH:mm:ss
time-zone
:
GMT+8
time-zone
:
GMT+8
rabbitmq
:
host
:
@
profiles.rabbitmq.host@
port
:
@
profiles.rabbitmq.port@
username
:
@
profiles.rabbitmq.username@
password
:
@
profiles.rabbitmq.password@
virtualHost
:
@
profiles.rabbitmq.virtualhost@
cloud
:
cloud
:
nacos
:
nacos
:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
...
...
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