|
@@ -15,22 +15,23 @@ import ( |
|
@@ -15,22 +15,23 @@ import ( |
15
|
|
15
|
|
16
|
func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error {
|
16
|
func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error {
|
17
|
var receivedMsg domain.ReceivedMessage
|
17
|
var receivedMsg domain.ReceivedMessage
|
|
|
18
|
+
|
|
|
19
|
+ log.Logger.Debug(string(msgData.Value))
|
18
|
err := json.Unmarshal(msgData.Value, &receivedMsg)
|
20
|
err := json.Unmarshal(msgData.Value, &receivedMsg)
|
19
|
if err != nil {
|
21
|
if err != nil {
|
|
|
22
|
+ log.Logger.Error("解析ReceivedMessage 失败" + err.Error())
|
20
|
return err
|
23
|
return err
|
21
|
}
|
24
|
}
|
22
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
25
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
23
|
if err != nil {
|
26
|
if err != nil {
|
24
|
return err
|
27
|
return err
|
25
|
}
|
28
|
}
|
26
|
- transactionContext.StartTransaction()
|
|
|
27
|
- var transactionIsSucceed bool
|
29
|
+ _ = transactionContext.StartTransaction()
|
|
|
30
|
+
|
28
|
defer func() {
|
31
|
defer func() {
|
29
|
- if transactionIsSucceed {
|
|
|
30
|
- transactionContext.CommitTransaction()
|
|
|
31
|
- } else {
|
|
|
32
|
- transactionContext.RollbackTransaction()
|
|
|
33
|
- }
|
32
|
+
|
|
|
33
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
34
|
+
|
34
|
}()
|
35
|
}()
|
35
|
|
36
|
|
36
|
msgRepo := factory.CreateReceivedMessageRepository(map[string]interface{}{
|
37
|
msgRepo := factory.CreateReceivedMessageRepository(map[string]interface{}{
|
|
@@ -87,5 +88,6 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { |
|
@@ -87,5 +88,6 @@ func SyncDataBusinessAdmin(msgData *sarama.ConsumerMessage) error { |
87
|
log.Logger.Error(" 保存新消息发生错误 " + err.Error())
|
88
|
log.Logger.Error(" 保存新消息发生错误 " + err.Error())
|
88
|
log.Logger.Info("异常消息message_id=" + strconv.FormatInt(receivedMsg.MessageId, 10))
|
89
|
log.Logger.Info("异常消息message_id=" + strconv.FormatInt(receivedMsg.MessageId, 10))
|
89
|
}
|
90
|
}
|
|
|
91
|
+ _ = transactionContext.CommitTransaction()
|
90
|
return nil
|
92
|
return nil
|
91
|
} |
93
|
} |