Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-performance
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
姜武杰
clx-performance
Commits
b57bb9ba
提交
b57bb9ba
authored
11月 03, 2023
作者:
huyufan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改BUG
上级
c401bdd5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
43 行增加
和
38 行删除
+43
-38
RabbitBeanConfig.java
...ain/java/com/clx/performance/config/RabbitBeanConfig.java
+40
-35
OneGoodsOrderStrategy.java
.../clx/performance/strategy/impl/OneGoodsOrderStrategy.java
+1
-1
ThreeGoodsOrderStrategy.java
...lx/performance/strategy/impl/ThreeGoodsOrderStrategy.java
+1
-1
TwoGoodsOrderStrategy.java
.../clx/performance/strategy/impl/TwoGoodsOrderStrategy.java
+1
-1
没有找到文件。
performance-web/src/main/java/com/clx/performance/config/RabbitBeanConfig.java
浏览文件 @
b57bb9ba
package
com
.
clx
.
performance
.
config
;
package
com
.
clx
.
performance
.
config
;
import
com.clx.performance.constant.RabbitKeyConstants
;
import
com.clx.performance.constant.RabbitKeyConstants
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.*
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.amqp.core.DirectExchange
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -93,32 +91,32 @@ public class RabbitBeanConfig {
...
@@ -93,32 +91,32 @@ public class RabbitBeanConfig {
/**
/**
* 货单挂单队列
//
* 货单挂单队列
* @return
//
* @return
*/
//
*/
@Bean
//
@Bean
public
Queue
orderGoodsOnQueue
()
{
//
public Queue orderGoodsOnQueue() {
Map
<
String
,
Object
>
params
=
new
HashMap
<>(
6
);
//
Map<String, Object> params = new HashMap<>(6);
params
.
put
(
"x-dead-letter-exchange"
,
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_EXCHANGE
);
//
params.put("x-dead-letter-exchange", RabbitKeyConstants.ORDER_GOODS_ON_DEAD_EXCHANGE);
params
.
put
(
"x-dead-letter-routing-key"
,
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_ROUTE_KEY
);
//
params.put("x-dead-letter-routing-key", RabbitKeyConstants.ORDER_GOODS_ON_DEAD_ROUTE_KEY);
return
new
Queue
(
RabbitKeyConstants
.
ORDER_GOODS_ON_QUEUE
,
true
,
false
,
false
,
params
);
//
return new Queue(RabbitKeyConstants.ORDER_GOODS_ON_QUEUE, true, false, false, params);
}
//
}
//
/**
//
/**
* 货单挂单中交换机
//
* 货单挂单中交换机
**/
//
**/
@Bean
//
@Bean
public
DirectExchange
orderGoodsOnExchange
()
{
//
public DirectExchange orderGoodsOnExchange() {
return
new
DirectExchange
(
RabbitKeyConstants
.
ORDER_GOODS_ON_EXCHANGE
);
//
return new DirectExchange(RabbitKeyConstants.ORDER_GOODS_ON_EXCHANGE);
}
//
}
//
/**
//
/**
* 货单挂单中绑定
//
* 货单挂单中绑定
*/
//
*/
@Bean
//
@Bean
public
Binding
orderGoodsOnExchangeBind
()
{
//
public Binding orderGoodsOnExchangeBind() {
return
BindingBuilder
.
bind
(
orderGoodsOnQueue
()).
to
(
orderGoodsOnExchange
()).
with
(
RabbitKeyConstants
.
ORDER_GOODS_ON_ROUTE_KEY
);
//
return BindingBuilder.bind(orderGoodsOnQueue()).to(orderGoodsOnExchange()).with(RabbitKeyConstants.ORDER_GOODS_ON_ROUTE_KEY);
}
//
}
/**
/**
* 死信队列:死信队列处理延迟消息货单挂单
* 死信队列:死信队列处理延迟消息货单挂单
...
@@ -133,19 +131,26 @@ public class RabbitBeanConfig {
...
@@ -133,19 +131,26 @@ public class RabbitBeanConfig {
* 货单挂单中交换机:死信队列处理延迟消息
* 货单挂单中交换机:死信队列处理延迟消息
**/
**/
@Bean
@Bean
public
DirectExchange
orderGoodsOnDeadExchange
()
{
public
CustomExchange
orderGoodsOnDeadExchange
()
{
return
new
DirectExchange
(
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_EXCHANGE
);
Map
<
String
,
Object
>
arguments
=
new
HashMap
<>();
//设置路由模式 direct模式
arguments
.
put
(
"x-delayed-type"
,
"direct"
);
return
new
CustomExchange
(
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_EXCHANGE
,
"x-delayed-message"
,
true
,
false
,
arguments
);
}
}
/**
/**
* 货单挂单中绑定:死信队列处理延迟消息
* 货单挂单中绑定:死信队列处理延迟消息
*/
*/
// @Bean
// public Binding orderGoodsDeadExchangeBind() {
// return BindingBuilder.bind(orderGoodsOnDeadQueue()).to(orderGoodsOnDeadExchange()).with(RabbitKeyConstants.ORDER_GOODS_ON_DEAD_ROUTE_KEY);
// }
//绑定交换机,队列和routingKey
@Bean
@Bean
public
Binding
orderGoodsDeadExchangeBind
(
)
{
public
Binding
delayedQueueBindingDelayedExchange
(
@Qualifier
(
"orderGoodsOnDeadQueue"
)
Queue
queue
,
@Qualifier
(
"orderGoodsOnDeadExchange"
)
CustomExchange
customExchange
)
{
return
BindingBuilder
.
bind
(
orderGoodsOnDeadQueue
()).
to
(
orderGoodsOnDeadExchange
()).
with
(
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_ROUTE_KEY
);
return
BindingBuilder
.
bind
(
queue
).
to
(
customExchange
).
with
(
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD_ROUTE_KEY
).
noargs
(
);
}
}
/**
/**
* 订单取消队列
* 订单取消队列
* @return
* @return
...
...
performance-web/src/main/java/com/clx/performance/strategy/impl/OneGoodsOrderStrategy.java
浏览文件 @
b57bb9ba
...
@@ -216,7 +216,7 @@ public class OneGoodsOrderStrategy extends GoodsOrderStrategy implements Initial
...
@@ -216,7 +216,7 @@ public class OneGoodsOrderStrategy extends GoodsOrderStrategy implements Initial
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
rabbitTemplate
.
send
(
rabbitTemplate
.
send
(
RabbitKeyConstants
.
ORDER_GOODS_ON_
EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON
_ROUTE_KEY
,
message
RabbitKeyConstants
.
ORDER_GOODS_ON_
DEAD_EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD
_ROUTE_KEY
,
message
);
);
}
}
}
}
...
...
performance-web/src/main/java/com/clx/performance/strategy/impl/ThreeGoodsOrderStrategy.java
浏览文件 @
b57bb9ba
...
@@ -231,7 +231,7 @@ public class ThreeGoodsOrderStrategy extends GoodsOrderStrategy implements Initi
...
@@ -231,7 +231,7 @@ public class ThreeGoodsOrderStrategy extends GoodsOrderStrategy implements Initi
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
rabbitTemplate
.
send
(
rabbitTemplate
.
send
(
RabbitKeyConstants
.
ORDER_GOODS_ON_
EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON
_ROUTE_KEY
,
message
RabbitKeyConstants
.
ORDER_GOODS_ON_
DEAD_EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD
_ROUTE_KEY
,
message
);
);
}
}
}
}
...
...
performance-web/src/main/java/com/clx/performance/strategy/impl/TwoGoodsOrderStrategy.java
浏览文件 @
b57bb9ba
...
@@ -249,7 +249,7 @@ public class TwoGoodsOrderStrategy extends GoodsOrderStrategy implements Initial
...
@@ -249,7 +249,7 @@ public class TwoGoodsOrderStrategy extends GoodsOrderStrategy implements Initial
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
message
.
getMessageProperties
().
setExpiration
(
String
.
valueOf
(
epochMilli
));
rabbitTemplate
.
send
(
rabbitTemplate
.
send
(
RabbitKeyConstants
.
ORDER_GOODS_ON_
EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON
_ROUTE_KEY
,
message
RabbitKeyConstants
.
ORDER_GOODS_ON_
DEAD_EXCHANGE
,
RabbitKeyConstants
.
ORDER_GOODS_ON_DEAD
_ROUTE_KEY
,
message
);
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论