|
@ -1,6 +1,7 @@ |
|
|
package com.epmet.mq; |
|
|
package com.epmet.mq; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; |
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
@ -21,6 +22,7 @@ import org.slf4j.LoggerFactory; |
|
|
import javax.annotation.PreDestroy; |
|
|
import javax.annotation.PreDestroy; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -32,7 +34,7 @@ import java.util.stream.Collectors; |
|
|
* @date 2021.03.03 16:10 |
|
|
* @date 2021.03.03 16:10 |
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class GroupAchievementCustomListener implements MessageListenerConcurrently { |
|
|
public class ProjectChangedCustomListener implements MessageListenerConcurrently { |
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
|
|
|
|
|
@ -51,11 +53,14 @@ public class GroupAchievementCustomListener implements MessageListenerConcurrent |
|
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; |
|
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void consumeMessage(String customerId) { |
|
|
private void consumeMessage(String msg) { |
|
|
logger.info("receive customerId:{}", JSON.toJSONString(customerId)); |
|
|
logger.info("receive customerId:{}", JSON.toJSONString(msg)); |
|
|
|
|
|
ProjectChangedMQMsg msgObj = JSON.parseObject(msg, ProjectChangedMQMsg.class); |
|
|
|
|
|
|
|
|
DistributedLock distributedLock = null; |
|
|
DistributedLock distributedLock = null; |
|
|
RLock lock = null; |
|
|
RLock lock = null; |
|
|
try { |
|
|
try { |
|
|
|
|
|
String customerId = msgObj.getCustomerId(); |
|
|
distributedLock = SpringContextUtils.getBean(DistributedLock.class); |
|
|
distributedLock = SpringContextUtils.getBean(DistributedLock.class); |
|
|
lock = distributedLock.getLock(String.format("lock:project_changed:%s", customerId) |
|
|
lock = distributedLock.getLock(String.format("lock:project_changed:%s", customerId) |
|
|
,30L, 30L, TimeUnit.SECONDS); |
|
|
,30L, 30L, TimeUnit.SECONDS); |
|
@ -76,6 +81,13 @@ public class GroupAchievementCustomListener implements MessageListenerConcurrent |
|
|
String dateId = DimIdGenerator.getDateDimId(new Date()); |
|
|
String dateId = DimIdGenerator.getDateDimId(new Date()); |
|
|
extractOriginFormDTO.setDateId(dateId); |
|
|
extractOriginFormDTO.setDateId(dateId); |
|
|
Future<?> aBoolean = SpringContextUtils.getBean(FactOriginExtractService.class).submitProjectRelationData(extractOriginFormDTO,null); |
|
|
Future<?> aBoolean = SpringContextUtils.getBean(FactOriginExtractService.class).submitProjectRelationData(extractOriginFormDTO,null); |
|
|
|
|
|
try { |
|
|
|
|
|
aBoolean.get(); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (ExecutionException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
if (aBoolean.isDone()){ |
|
|
if (aBoolean.isDone()){ |
|
|
SpringContextUtils.getBean(ScreenExtractService.class).extractPartData(customerId,dateId); |
|
|
SpringContextUtils.getBean(ScreenExtractService.class).extractPartData(customerId,dateId); |
|
|
} |
|
|
} |
|
@ -85,7 +97,7 @@ public class GroupAchievementCustomListener implements MessageListenerConcurrent |
|
|
logger.error("【RocketMQ】消费项目变动消息失败:",e); |
|
|
logger.error("【RocketMQ】消费项目变动消息失败:",e); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
// 不是我们自己抛出的异常,可以让MQ重试
|
|
|
// 不是我们自己抛出的异常,可以让MQ重试
|
|
|
logger.error("【RocketMQ】消费项目变动消息失败:",e); |
|
|
logger.error("【RocketMQ】消费项目变动消息异常:",e); |
|
|
throw e; |
|
|
throw e; |
|
|
} finally { |
|
|
} finally { |
|
|
if (distributedLock != null){ |
|
|
if (distributedLock != null){ |