提交 f29dae2a 作者: 沈振路

rabbit配置

上级 32db6e71
......@@ -223,6 +223,13 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
......
......@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @date 2022/9/15 18:13
*/
@SpringBootApplication
@EnableScheduling
//@EnableScheduling
@MapperScan("com.yaoyaozw.customer.mapper")
@EnableFeignClients
@EnableAsync
......
......@@ -27,6 +27,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
......@@ -34,6 +36,7 @@ import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
......@@ -56,7 +59,7 @@ public class CustomerServiceCommonAsyncComponent {
@Autowired
private CrowdPackageConditionMatchService matchService;
@Autowired
private RedisTemplate redisTemplate;
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private ReferralFeignClient referralFeignClient;
@Autowired
......@@ -67,6 +70,8 @@ public class CustomerServiceCommonAsyncComponent {
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerGraphicsDelayMapper customerGraphicsDelayMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Async("myExecutor")
......@@ -587,5 +592,25 @@ public class CustomerServiceCommonAsyncComponent {
return userEntityList;
}
public void controlSunshineFrequency() {
RegisterUserEntity registerUserEntity = new RegisterUserEntity();
registerUserEntity.setOpenId("abc");
registerUserEntity.setId(111L);
registerUserEntity.setCustomerSort(10);
String jsonStr = JSONUtil.toJsonStr(registerUserEntity);
rabbitTemplate.convertAndSend("TTL_EXCHANGE", "yg_limit", jsonStr);
}
@RabbitListener(queues = "DEATH_QUEUE")
public void handle(String message) {
RegisterUserEntity registerUserEntity = JSONUtil.toBean(message, RegisterUserEntity.class);
LOCAL_LOG.info("------------------收到消息:" + registerUserEntity);
}
}
package com.yaoyaozw.customer.configs;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
/**
* @author darker
* @date 2022/10/21 16:04
*/
@Configuration
public class RabbitConfig {
@Bean
public Queue directQueue(){
Map<String, Object> map = new HashMap<>(4);
map.put("x-dead-letter-exchange", "DEATH_EXCHANGE");
map.put("x-dead-letter-routing-key", "death");
map.put("x-max-length", 30);
map.put("x-message-ttl", 60000);
map.put("x-overflow", 60000);
return new Queue("YG_ACCESS_LIMIT", true, false, false, map);
}
@Bean
public DirectExchange directExchange(){
return new DirectExchange("TTL_EXCHANGE");
}
@Bean
public Queue deathQueue(){
return new Queue("DEATH_QUEUE");
}
@Bean
public DirectExchange deathExchange(){
return new DirectExchange("DEATH_EXCHANGE");
}
@Bean
public Binding bindingDirect(){
return BindingBuilder.bind(directQueue()).to(directExchange()).with("yg_limit");
}
@Bean
public Binding bindingDeath(){
return BindingBuilder.bind(deathQueue()).to(deathExchange()).with("death");
}
}
......@@ -38,6 +38,8 @@ public class CustomerDelayListVO implements Serializable {
@ApiModelProperty("时间间隔")
private String timeInterval;
private Integer peopleNum;
private Long timeStamp;
@ApiModelProperty("发送状态值")
......
......@@ -49,7 +49,8 @@
ai.nick_name as accountName,
cgd.post_sort as postSort,
cgd.time_interval as `timestamp` ,
s_dic.dic_value as sendStatus
s_dic.dic_value as sendStatus,
cgd.send_num as peopleNum
from customer_graphics_delay cgd
left join authorizer_info ai
......@@ -60,7 +61,7 @@
and s_dic.dic_key = cgd.send_status
where cgd.is_deleted = 0
<if test="queryDto.appId != null and queryDto.appId != ''">
<if test="queryDto.appId != null">
and cgd.app_id = #{queryDto.appId}
</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论