...
|
...
|
@@ -15,22 +15,23 @@ import ( |
|
|
|
|
|
func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error {
|
|
|
var receivedMsg domain.ReceivedMessage
|
|
|
|
|
|
log.Logger.Debug(string(msgData.Value))
|
|
|
err := json.Unmarshal(msgData.Value, &receivedMsg)
|
|
|
if err != nil {
|
|
|
log.Logger.Error("解析ReceivedMessage 失败" + err.Error())
|
|
|
return err
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
transactionContext.StartTransaction()
|
|
|
var transactionIsSucceed bool
|
|
|
_ = transactionContext.StartTransaction()
|
|
|
|
|
|
defer func() {
|
|
|
if transactionIsSucceed {
|
|
|
transactionContext.CommitTransaction()
|
|
|
} else {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}
|
|
|
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
|
|
|
}()
|
|
|
|
|
|
msgRepo := factory.CreateReceivedMessageRepository(map[string]interface{}{
|
...
|
...
|
@@ -87,5 +88,6 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { |
|
|
log.Logger.Error(" 保存新消息发生错误 " + err.Error())
|
|
|
log.Logger.Info("异常消息message_id=" + strconv.FormatInt(receivedMsg.MessageId, 10))
|
|
|
}
|
|
|
_ = transactionContext.CommitTransaction()
|
|
|
return nil
|
|
|
} |
...
|
...
|
|