更改MQ配置

This commit is contained in:
liuyingfang
2024-04-09 10:56:26 +08:00
parent d2550475b4
commit dd81edb51e
8 changed files with 35 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author lyf
@@ -47,11 +48,11 @@ public class HomeVO {
/**
* 店铺标签
*/
private String shopTag;
private List<String> shopTag;
/**
* 商品标签
*/
private String proTag;
private List<String> proTag;
/**
* 距离
*/
@@ -88,19 +89,19 @@ public class HomeVO {
this.distances = distances;
}
public String getShopTag() {
public List<String> getShopTag() {
return shopTag;
}
public void setShopTag(String shopTag) {
public void setShopTag(List<String> shopTag) {
this.shopTag = shopTag;
}
public String getProTag() {
public List<String> getProTag() {
return proTag;
}
public void setProTag(String proTag) {
public void setProTag(List<String> proTag) {
this.proTag = proTag;
}

View File

@@ -29,7 +29,7 @@ import java.util.*;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT})
//@RabbitListener(queues = {RabbitConstants.CART_QUEUE_PUT})
@Service
public class CartConsumer {
@@ -39,6 +39,7 @@ public class CartConsumer {
@Autowired
private CartService cartService;
@RabbitHandler
@RabbitListener(queues = {"${queue}"})
public void listener(String message) {
try {
JSONObject jsonObject = JSON.parseObject(message);

View File

@@ -27,7 +27,8 @@ public class RabbitConfig {
@Value("${spring.rabbitmq.password}")
private String password;
@Value("${prod}")
private String prod;
@Bean
@@ -49,17 +50,17 @@ public class RabbitConfig {
}
@Bean
public DirectExchange defaultExchange_Register() {
return new DirectExchange(RabbitConstants.CART_PUT);
return new DirectExchange(RabbitConstants.CART_PUT+prod);
}
@Bean
public Queue queuePut_Register() {
return new Queue(RabbitConstants.CART_QUEUE_PUT, true); //队列持久
return new Queue(RabbitConstants.CART_QUEUE_PUT+prod, true); //队列持久
}
@Bean
public Binding bindingPut_Register() {
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT);
return BindingBuilder.bind(queuePut_Register()).to(defaultExchange_Register()).with(RabbitConstants.CART_ROUTINGKEY_PUT+prod);
}

View File

@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -17,6 +18,8 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
private RabbitTemplate rabbitTemplate;
@Value("${prod}")
private String prod;
@Autowired
public RabbitProducer(RabbitTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
@@ -25,7 +28,7 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public void putCart(String content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT, RabbitConstants.CART_ROUTINGKEY_PUT, content, correlationId);
rabbitTemplate.convertAndSend(RabbitConstants.CART_PUT+prod, RabbitConstants.CART_ROUTINGKEY_PUT+prod, content, correlationId);
}
public void putOrderCollect(String content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());

View File

@@ -15,6 +15,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -78,8 +79,12 @@ public class HomePageService {
if (o.getShopId().equals(tbShopInfo.getId().toString())) {
homeVO.setShopName(tbShopInfo.getShopName());
homeVO.setImage(tbShopInfo.getLogo());
TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag()));
homeVO.setShopTag(tbPlatformDict == null?"":tbPlatformDict.getName());
if (tbShopInfo.getTag() == null){
homeVO.setShopTag(new ArrayList<>());
}else {
TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag()));
homeVO.setShopTag(tbPlatformDict == null ? new ArrayList<>() : Collections.singletonList(tbPlatformDict.getName()));
}
}
}
for (TbProduct tbProduct : product.get()) {
@@ -101,7 +106,7 @@ public class HomePageService {
}
for (TagProductVO tagProductVO :dictPro.get()) {
if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){
homeVO.setProTag(tagProductVO.getTags());
homeVO.setProTag(Collections.singletonList(tagProductVO.getTags()));
}
}
homeVO.setEndTime(DateUtils.getTodayEndTimeAsString());

View File

@@ -15,7 +15,8 @@ spring:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 5
# redis服务器地址默认为localhost
host: 101.37.12.135
# host: 101.37.12.135
host: 127.0.0.1
# redis端口默认为6379
port: 6379
# redis访问密码默认为空
@@ -54,6 +55,7 @@ ysk:
callBackurl: https://p40312246f.goho.co/cashierService/notify/notifyCallBack
callBackIn: https://p40312246f.goho.co/cashierService/notify/memberInCallBack
default: 18710449883
prod: prod1
queue: cart_queue_putprod1

View File

@@ -56,6 +56,7 @@ ysk:
callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
default: 19191703856
prod: prod1
queue: cart_queue_put1prod1

View File

@@ -1,5 +1,5 @@
server:
port: 9888
port: 9889
spring:
datasource:
url: jdbc:mysql://rm-bp1b572nblln4jho2.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false
@@ -56,6 +56,7 @@ ysk:
callBackurl: https://cashier.sxczgkj.cn/cashierService/notify/notifyCallBack
callBackIn: https://cashier.sxczgkj.cn/cashierService/notify/memberInCallBack
default: 19191703856
prod: prod2
queue: cart_queue_put1prod2