Commit 31517b8ca92426f9060b45beb02c123042845450

Authored by shaofan
1 parent bf132471

Add logging to `TransportInfoServiceImpl` and handle Redis publish exceptions

sl-express-ms-transport-info-service/src/main/java/com/sl/transport/info/service/impl/TransportInfoServiceImpl.java
@@ -7,6 +7,7 @@ import com.sl.transport.info.config.RedisConfig; @@ -7,6 +7,7 @@ import com.sl.transport.info.config.RedisConfig;
7 import com.sl.transport.info.entity.TransportInfoDetail; 7 import com.sl.transport.info.entity.TransportInfoDetail;
8 import com.sl.transport.info.entity.TransportInfoEntity; 8 import com.sl.transport.info.entity.TransportInfoEntity;
9 import com.sl.transport.info.service.TransportInfoService; 9 import com.sl.transport.info.service.TransportInfoService;
  10 +import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.cache.annotation.CachePut; 12 import org.springframework.cache.annotation.CachePut;
12 import org.springframework.cache.annotation.Cacheable; 13 import org.springframework.cache.annotation.Cacheable;
@@ -17,12 +18,14 @@ import org.springframework.data.redis.core.StringRedisTemplate; @@ -17,12 +18,14 @@ import org.springframework.data.redis.core.StringRedisTemplate;
17 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
18 19
19 @Service 20 @Service
  21 +@Slf4j
20 public class TransportInfoServiceImpl implements TransportInfoService { 22 public class TransportInfoServiceImpl implements TransportInfoService {
21 23
22 @Autowired 24 @Autowired
23 private MongoTemplate mongoTemplate; 25 private MongoTemplate mongoTemplate;
24 @Autowired 26 @Autowired
25 private Cache transportInfoCache; 27 private Cache transportInfoCache;
  28 + @Autowired
26 private StringRedisTemplate stringRedisTemplate; 29 private StringRedisTemplate stringRedisTemplate;
27 @Autowired 30 @Autowired
28 private BloomFilterServiceImpl bloomFilterService; 31 private BloomFilterServiceImpl bloomFilterService;
@@ -59,7 +62,11 @@ public class TransportInfoServiceImpl implements TransportInfoService { @@ -59,7 +62,11 @@ public class TransportInfoServiceImpl implements TransportInfoService {
59 62
60 // 清除缓存中的数据 63 // 清除缓存中的数据
61 // transportInfoCache.invalidate(transportOrderId); 64 // transportInfoCache.invalidate(transportOrderId);
62 - stringRedisTemplate.convertAndSend(RedisConfig.CHANNEL_TOPIC, transportOrderId); 65 + try {
  66 + stringRedisTemplate.convertAndSend(RedisConfig.CHANNEL_TOPIC, transportOrderId);
  67 + } catch (Exception e) {
  68 + log.error("失败", e);
  69 + }
63 70
64 return mongoTemplate.save(transportInfoEntity); 71 return mongoTemplate.save(transportInfoEntity);
65 } 72 }