CAICAIIs opened a new pull request, #1054:
URL: https://github.com/apache/incubator-seata-go/pull/1054

   <!--  Thanks for sending a pull request!
   -->
   <!-- Please make sure you have read and understood the contributing 
guidelines -->
   
   - [x] I have registered the PR 
[changes](https://github.com/apache/incubator-seata-go/tree/master/changes).
   
   **What this PR does**:
   This PR implements RocketMQ TCC integration for distributed transactions, 
enabling RocketMQ transaction messages to participate in Seata global 
transactions.
   
   1. TCCRocketMQAction - Implements TwoPhaseInterface to wrap RocketMQ 
transaction messages as TCC resources:
   - Prepare: Sends half-message and stores transaction metadata
   - Commit: Relies on broker check-back mechanism
   - Rollback: Relies on broker check-back mechanism
   2. SeataMQProducer - User-facing producer wrapper:
   - Auto-detects global transaction context via tm.IsGlobalTx(ctx)
   - Routes messages to TCC flow when in global transaction
   - Falls back to normal send for non-transactional messages
   3. SeataTransactionListener - Handles broker transaction state queries:
   - ExecuteLocalTransaction: Returns UnknownState to defer decision
   - CheckLocalTransaction: Queries TC for global transaction status
   4. Producer Factory - Singleton pattern for producer lifecycle management
   **Which issue(s) this PR fixes**:
   
   ### Usage Example
   ```go
   // Initialize producer
   cfg := &rocketmq.SeataMQProducerConfig{
       NameServerAddrs: []string{"127.0.0.1:9876"},
       GroupName:       "seata-producer-group",
   }
   rocketmq.InitSeataMQProducer(cfg)
   defer rocketmq.ShutdownSeataMQProducer()
   producer, _ := rocketmq.GetSeataMQProducer()
   // Send message in global transaction
   tm.WithGlobalTx(ctx, tm.GtxConfig{Name: "order-create"}, func(ctx 
context.Context) error {
       msg := primitive.NewMessage("order-topic", []byte("order created"))
       _, err := producer.Send(ctx, msg)
       return err
   })
   ```
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related 
issues/tests in a comment and do not use `Fixes`_*
   -->
   
   Related to #765 
   
   **Special notes for your reviewer**:
   1. Message Property Injection: XID and BranchId are injected into message 
properties for transaction correlation during broker check-back.
   2. Broker Check-back: Commit/Rollback relies on RocketMQ's built-in 
check-back mechanism. When the broker queries transaction state, 
CheckLocalTransaction queries TC's global transaction status.
   3. API Compatibility: Uses rocketmq-client-go/v2 public APIs only.
   4. Thread Safety: Producer uses read/write mutex for safe concurrent access.
   
   
   **Does this PR introduce a user-facing change?**:
   
   
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires 
additional action from users switching to the new release, include the string 
"action required".
   -->
   
   ```release-note
   Add RocketMQ TCC integration support for distributed transaction messaging
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to