提交修改
This commit is contained in:
parent
f26b69361b
commit
65b585f956
@ -14,6 +14,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wutao
|
* @author wutao
|
||||||
* @description mq配置
|
* @description mq配置
|
||||||
@ -74,7 +75,7 @@ public class RabbitConfig {
|
|||||||
// ---------------------------- 定义exchange ---------------------------------
|
// ---------------------------- 定义exchange ---------------------------------
|
||||||
// 定义广播模式的延时交换机 无需绑定路由
|
// 定义广播模式的延时交换机 无需绑定路由
|
||||||
@Bean
|
@Bean
|
||||||
FanoutExchange delayExchange(@Value("${eb.config.rabbitQueue.delayExchangeName}") String delay_exchange_name){
|
FanoutExchange delayExchange(@Value("${eb.config.rabbitQueue.delayExchangeName}") String delay_exchange_name) {
|
||||||
Map<String, Object> args = new HashMap<String, Object>();
|
Map<String, Object> args = new HashMap<String, Object>();
|
||||||
args.put("x-delayed-type", "direct");
|
args.put("x-delayed-type", "direct");
|
||||||
FanoutExchange topicExchange = new FanoutExchange(delay_exchange_name, true, false, args);
|
FanoutExchange topicExchange = new FanoutExchange(delay_exchange_name, true, false, args);
|
||||||
@ -85,13 +86,13 @@ public class RabbitConfig {
|
|||||||
// 绑定延时队列与交换机
|
// 绑定延时队列与交换机
|
||||||
@Bean
|
@Bean
|
||||||
public Binding delayPayBind(@Value("${eb.config.rabbitQueue.delayQueue}") String delay_queue_name,
|
public Binding delayPayBind(@Value("${eb.config.rabbitQueue.delayQueue}") String delay_queue_name,
|
||||||
@Value("${eb.config.rabbitQueue.delayExchangeName}") String delay_exchange_name ) {
|
@Value("${eb.config.rabbitQueue.delayExchangeName}") String delay_exchange_name) {
|
||||||
return BindingBuilder.bind(delayQueue(delay_queue_name)).to(delayExchange(delay_exchange_name));
|
return BindingBuilder
|
||||||
|
.bind(delayQueue(delay_queue_name))
|
||||||
|
.to(delayExchange(delay_exchange_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
@Bean(name = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
||||||
public SimpleRabbitListenerContainerFactory accountAmountQueueSimpleRabbitListenerContainerFactory() {
|
public SimpleRabbitListenerContainerFactory accountAmountQueueSimpleRabbitListenerContainerFactory() {
|
||||||
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
||||||
@ -103,20 +104,16 @@ public class RabbitConfig {
|
|||||||
return listenerContainerFactory;
|
return listenerContainerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Queue accountLogNameQueue(@Value("${eb.config.rabbitQueue.accountLogName}") String queueName) {
|
public Queue accountLogNameQueue(@Value("${eb.config.rabbitQueue.accountLogName}") String queueName) {
|
||||||
return new Queue(queueName);
|
return new Queue(queueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Queue urlStatisticQueue(@Value("${eb.config.rabbitQueue.urlStatisticQueue}") String queueName) {
|
public Queue urlStatisticQueue(@Value("${eb.config.rabbitQueue.urlStatisticQueue}") String queueName) {
|
||||||
return new Queue(queueName);
|
return new Queue(queueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "accountLogNameQueueSimpleRabbitListenerContainerFactory")
|
@Bean(name = "accountLogNameQueueSimpleRabbitListenerContainerFactory")
|
||||||
public SimpleRabbitListenerContainerFactory accountLogNameQueueSimpleRabbitListenerContainerFactory() {
|
public SimpleRabbitListenerContainerFactory accountLogNameQueueSimpleRabbitListenerContainerFactory() {
|
||||||
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
||||||
|
|||||||
@ -56,4 +56,4 @@ spring:
|
|||||||
#设置消息发送回调
|
#设置消息发送回调
|
||||||
publisher-returns: true
|
publisher-returns: true
|
||||||
publisher-confirm-type: simple
|
publisher-confirm-type: simple
|
||||||
virtual-host: /heyu
|
virtual-host: /
|
||||||
@ -108,7 +108,7 @@ public class AppTestController {
|
|||||||
@RequestMapping("/delay")
|
@RequestMapping("/delay")
|
||||||
public R delay(@RequestBody AppOrderRequest vvOrderRequest) throws Exception {
|
public R delay(@RequestBody AppOrderRequest vvOrderRequest) throws Exception {
|
||||||
PackageDelivedDelayDTO dto = new PackageDelivedDelayDTO();
|
PackageDelivedDelayDTO dto = new PackageDelivedDelayDTO();
|
||||||
dto.setPackageId("10");
|
dto.setPackageId(10L);
|
||||||
dto.setRole("test");
|
dto.setRole("test");
|
||||||
Date time = new Date();
|
Date time = new Date();
|
||||||
Date timeAfter15 = DateUtils.addSeconds(time, 10);
|
Date timeAfter15 = DateUtils.addSeconds(time, 10);
|
||||||
@ -116,6 +116,7 @@ public class AppTestController {
|
|||||||
dto.setDelayTime(DateUtils.formatDate(timeAfter15, com.heyu.api.data.utils.DateUtils.YYYY_MM_DD_HH_MM_SS));
|
dto.setDelayTime(DateUtils.formatDate(timeAfter15, com.heyu.api.data.utils.DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||||
|
|
||||||
int second = DateUtils.betweenSecond(time, timeAfter15);
|
int second = DateUtils.betweenSecond(time, timeAfter15);
|
||||||
|
log.info("xxxxxxxxxxxxx:{} ,second:{}",JSON.toJSONString(dto),second);
|
||||||
// 通过广播模式发布延时消息 延时30分钟 持久化消息 消费后销毁 这里无需指定路由,会广播至每个绑定此交换机的队列
|
// 通过广播模式发布延时消息 延时30分钟 持久化消息 消费后销毁 这里无需指定路由,会广播至每个绑定此交换机的队列
|
||||||
rabbitTemplate.convertAndSend(delayExchangeName, "", JSON.toJSONString(dto), message -> {
|
rabbitTemplate.convertAndSend(delayExchangeName, "", JSON.toJSONString(dto), message -> {
|
||||||
message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT);
|
message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT);
|
||||||
|
|||||||
@ -55,26 +55,7 @@ spring:
|
|||||||
host: 121.40.41.240
|
host: 121.40.41.240
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: rabit.iwulin.tech
|
host: 121.40.41.240
|
||||||
port: 32407
|
port: 5672
|
||||||
username: admin
|
username: admin
|
||||||
password: Ij_klfJ^$^_3IBs
|
password: XiIg37HKfQg2
|
||||||
listener:
|
|
||||||
simple:
|
|
||||||
# 设置手动ack回复
|
|
||||||
acknowledge-mode: manual
|
|
||||||
retry:
|
|
||||||
# 开启重试机制
|
|
||||||
enabled: true
|
|
||||||
# 重试次数
|
|
||||||
max-attempts: 3
|
|
||||||
# 重试最大间隔时间
|
|
||||||
max-interval: 100000
|
|
||||||
# 重试初始间隔时间
|
|
||||||
initial-interval: 100
|
|
||||||
# 间隔时间因子
|
|
||||||
multiplier: 20
|
|
||||||
#设置消息发送回调
|
|
||||||
publisher-returns: true
|
|
||||||
publisher-confirm-type: simple
|
|
||||||
virtual-host: /heyu
|
|
||||||
@ -49,26 +49,7 @@ spring:
|
|||||||
host: 172.16.5.230
|
host: 172.16.5.230
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 172.16.5.230
|
host: 121.40.41.240
|
||||||
port: 5672
|
port: 5672
|
||||||
username: user
|
username: admin
|
||||||
password: dk_eP^#fkLf30
|
password: XiIg37HKfQg2
|
||||||
listener:
|
|
||||||
simple:
|
|
||||||
# 设置手动ack回复
|
|
||||||
acknowledge-mode: manual
|
|
||||||
retry:
|
|
||||||
# 开启重试机制
|
|
||||||
enabled: true
|
|
||||||
# 重试次数
|
|
||||||
max-attempts: 3
|
|
||||||
# 重试最大间隔时间
|
|
||||||
max-interval: 100000
|
|
||||||
# 重试初始间隔时间
|
|
||||||
initial-interval: 100
|
|
||||||
# 间隔时间因子
|
|
||||||
multiplier: 20
|
|
||||||
#设置消息发送回调
|
|
||||||
publisher-returns: true
|
|
||||||
publisher-confirm-type: simple
|
|
||||||
virtual-host: /heyu
|
|
||||||
@ -60,8 +60,8 @@ eb:
|
|||||||
urlStatisticQueue: URL_STATISTIC_QUEUE
|
urlStatisticQueue: URL_STATISTIC_QUEUE
|
||||||
createDataQueue: CREATE_DATA_QUEUE_TEST
|
createDataQueue: CREATE_DATA_QUEUE_TEST
|
||||||
sendDingDingQueue: SEND_DING_DING_QUEUE_TEST
|
sendDingDingQueue: SEND_DING_DING_QUEUE_TEST
|
||||||
delayQueue: DELAY_QUEUE_NAME
|
delayQueue: DELAY_QUEUE_NAME_TEST
|
||||||
delayExchangeName: DELAY_EXCHANGE_NAME
|
delayExchangeName: DELAY_EXCHANGE_NAME_TEST
|
||||||
|
|
||||||
|
|
||||||
tencent:
|
tencent:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user