提交 f29dae2a 作者: 沈振路

rabbit配置

上级 32db6e71
...@@ -223,6 +223,13 @@ ...@@ -223,6 +223,13 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <artifactId>httpcore</artifactId>
......
...@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @date 2022/9/15 18:13 * @date 2022/9/15 18:13
*/ */
@SpringBootApplication @SpringBootApplication
@EnableScheduling //@EnableScheduling
@MapperScan("com.yaoyaozw.customer.mapper") @MapperScan("com.yaoyaozw.customer.mapper")
@EnableFeignClients @EnableFeignClients
@EnableAsync @EnableAsync
......
...@@ -27,6 +27,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO; ...@@ -27,6 +27,8 @@ import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
...@@ -34,6 +36,7 @@ import org.springframework.stereotype.Component; ...@@ -34,6 +36,7 @@ import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -56,7 +59,7 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -56,7 +59,7 @@ public class CustomerServiceCommonAsyncComponent {
@Autowired @Autowired
private CrowdPackageConditionMatchService matchService; private CrowdPackageConditionMatchService matchService;
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate<String, Object> redisTemplate;
@Autowired @Autowired
private ReferralFeignClient referralFeignClient; private ReferralFeignClient referralFeignClient;
@Autowired @Autowired
...@@ -67,6 +70,8 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -67,6 +70,8 @@ public class CustomerServiceCommonAsyncComponent {
private KanbanCommonMapper kanbanCommonMapper; private KanbanCommonMapper kanbanCommonMapper;
@Autowired @Autowired
private CustomerGraphicsDelayMapper customerGraphicsDelayMapper; private CustomerGraphicsDelayMapper customerGraphicsDelayMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Async("myExecutor") @Async("myExecutor")
...@@ -587,5 +592,25 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -587,5 +592,25 @@ public class CustomerServiceCommonAsyncComponent {
return userEntityList; 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 { ...@@ -38,6 +38,8 @@ public class CustomerDelayListVO implements Serializable {
@ApiModelProperty("时间间隔") @ApiModelProperty("时间间隔")
private String timeInterval; private String timeInterval;
private Integer peopleNum;
private Long timeStamp; private Long timeStamp;
@ApiModelProperty("发送状态值") @ApiModelProperty("发送状态值")
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
ai.nick_name as accountName, ai.nick_name as accountName,
cgd.post_sort as postSort, cgd.post_sort as postSort,
cgd.time_interval as `timestamp` , 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 from customer_graphics_delay cgd
left join authorizer_info ai left join authorizer_info ai
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
and s_dic.dic_key = cgd.send_status and s_dic.dic_key = cgd.send_status
where cgd.is_deleted = 0 where cgd.is_deleted = 0
<if test="queryDto.appId != null and queryDto.appId != ''"> <if test="queryDto.appId != null">
and cgd.app_id = #{queryDto.appId} and cgd.app_id = #{queryDto.appId}
</if> </if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论