Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[ISSUE #617] retrieve transactionid from property first
close #617

Signed-off-by: Tenhan Lee <tenhanlee@gmail.com>
  • Loading branch information
tenhan committed Mar 10, 2021
commit 1142be256a7c86e5112068e85fcb4eb1f76437fb
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 @@ -440,13 +440,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