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 7 import com.sl.transport.info.entity.TransportInfoDetail;
8 8 import com.sl.transport.info.entity.TransportInfoEntity;
9 9 import com.sl.transport.info.service.TransportInfoService;
  10 +import lombok.extern.slf4j.Slf4j;
10 11 import org.springframework.beans.factory.annotation.Autowired;
11 12 import org.springframework.cache.annotation.CachePut;
12 13 import org.springframework.cache.annotation.Cacheable;
... ... @@ -17,12 +18,14 @@ import org.springframework.data.redis.core.StringRedisTemplate;
17 18 import org.springframework.stereotype.Service;
18 19  
19 20 @Service
  21 +@Slf4j
20 22 public class TransportInfoServiceImpl implements TransportInfoService {
21 23  
22 24 @Autowired
23 25 private MongoTemplate mongoTemplate;
24 26 @Autowired
25 27 private Cache transportInfoCache;
  28 + @Autowired
26 29 private StringRedisTemplate stringRedisTemplate;
27 30 @Autowired
28 31 private BloomFilterServiceImpl bloomFilterService;
... ... @@ -59,7 +62,11 @@ public class TransportInfoServiceImpl implements TransportInfoService {
59 62  
60 63 // 清除缓存中的数据
61 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 71 return mongoTemplate.save(transportInfoEntity);
65 72 }
... ...