Merge remote-tracking branch 'origin/master'

20230922-ljl-fixBug
qiushengjie 1 year ago
commit 8616a2d264

@ -20,7 +20,6 @@ import com.ms.dal.entity.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.DateUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;

@ -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) {
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

@ -33,6 +33,7 @@ public class DsMessageCallbackService extends SPIBaseService implements Extensio
dsMessageService.addDsMessage(request.getShopId(), request.getPlatformPushMsgId(), request.getBizId(), request.getBizType(), request.getData());
return R.ok(CommonTool.successResult());
} catch (RuntimeException e) {
log.error("dsMessageCallbackError", e);
return R.ok(Ret.fail(e.getMessage()));
}
}

Loading…
Cancel
Save