Skip to content

Commit

Permalink
[ISSUE #617] retrieve transactionid from property first (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenhan authored Mar 16, 2021
1 parent f698f32 commit 05929da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions primitive/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
PropertyTranscationCheckTimes = "TRANSACTION_CHECK_TIMES"
PropertyCheckImmunityTimeInSeconds = "CHECK_IMMUNITY_TIME_IN_SECONDS"
PropertyShardingKey = "SHARDING_KEY"
PropertyTransactionID = "__transactionId__"
)

type Message struct {
Expand Down
9 changes: 8 additions & 1 deletion producer/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,20 @@ func (tp *transactionProducer) checkTransactionState() {
if uniqueKey == "" {
uniqueKey = callback.Msg.MsgId
}
transactionId := callback.Msg.GetProperty(primitive.PropertyTransactionID)
if transactionId == "" {
transactionId = callback.Header.TransactionId
}
if transactionId == "" {
transactionId = callback.Msg.TransactionId
}
header := &internal.EndTransactionRequestHeader{
CommitLogOffset: callback.Header.CommitLogOffset,
ProducerGroup: tp.producer.group,
TranStateTableOffset: callback.Header.TranStateTableOffset,
FromTransactionCheck: true,
MsgID: uniqueKey,
TransactionId: callback.Header.TransactionId,
TransactionId: transactionId,
CommitOrRollback: tp.transactionState(localTransactionState),
}

Expand Down

0 comments on commit 05929da

Please sign in to comment.