CutDownPriceActivityConsumer.java
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.yoho.dsf.mqapi.consumer;
import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.redis.CacheKeyEnum;
import com.yoho.activity.common.redis.RedisValueCache;
import com.yoho.activity.dal.CutDownPriceActivityMapper;
import com.yoho.activity.dal.model.CutDownPriceActivity;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.dsf.mqapi.constants.MqConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service(value="cutDownPriceActivityConsumer")
public class CutDownPriceActivityConsumer implements YhConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(CutDownPriceActivityConsumer.class);
@Autowired
private CutDownPriceActivityMapper cutDownPriceActivityMapper;
@Autowired
private RedisValueCache redisValueCache;
@Override
public void handleMessage(Object message) {
LOGGER.info("begin CutDownPriceActivityConsumer.handleMessage message is:{}, topic is:{}", MqConstants.MQ_SYN_CUTDOWNPRICE_ACTIVITY);
try {
CutDownPriceActivity cutDownPriceActivity = JSONObject.parseObject(String.valueOf(message), CutDownPriceActivity.class);
if (null != cutDownPriceActivity){
cutDownPriceActivityMapper.updateCutDownPriceActivity(cutDownPriceActivity);
//更新的时候清除缓存
if (cutDownPriceActivity.getActivityId() != null){
String redisKeySuffix = cutDownPriceActivity.getActivityId() + "";
redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_ACTIVITYBO_INFO,redisKeySuffix);
}
}
} catch (Exception e) {
LOGGER.warn("handle CutDownPriceActivityConsumer info message failed!! message is " + String.valueOf(message),e);
}
}
}