|
|
|
@ -13,8 +13,11 @@ import com.ms.dal.entity.DsMessageConsumerQueue;
|
|
|
|
|
import com.ms.dal.mapper.DsMessageMapper;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
|
|
import org.springframework.lang.Nullable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
@ -25,6 +28,9 @@ import java.util.Objects;
|
|
|
|
|
@Slf4j
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
public class DsMessageServiceImpl implements DsMessageService{
|
|
|
|
|
private final DataSourceTransactionManager dataSourceTransactionManager;
|
|
|
|
|
private final TransactionDefinition transactionDefinition;
|
|
|
|
|
|
|
|
|
|
private DsMessageMapper dsMessageMapper;
|
|
|
|
|
private DsMessageConsumerBufferService dsMessageConsumerBufferService;
|
|
|
|
|
private DsMessageConsumerQueueService dsMessageConsumerQueueService;
|
|
|
|
@ -113,10 +119,17 @@ public class DsMessageServiceImpl implements DsMessageService{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void addDsMessage(Long shopId, Long platformPushMsgId, String bizId, String bizType, String data) {
|
|
|
|
|
DsMessage dsMessage = add(shopId, platformPushMsgId, bizId, bizType, data);
|
|
|
|
|
dsMessageConsumerBufferService.addBuffer(shopId, dsMessage.getDsMessageId(), null);
|
|
|
|
|
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
|
|
|
|
try {
|
|
|
|
|
log.error("addDsMessagePlatformPushMsgId" + platformPushMsgId);
|
|
|
|
|
DsMessage dsMessage = add(shopId, platformPushMsgId, bizId, bizType, data);
|
|
|
|
|
dsMessageConsumerBufferService.addBuffer(shopId, dsMessage.getDsMessageId(), null);
|
|
|
|
|
dataSourceTransactionManager.commit(transactionStatus);
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
log.error("addDsMessageError", e);
|
|
|
|
|
dataSourceTransactionManager.rollback(transactionStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|