DaaS / Products / Distributed Transaction to Customer Notification Pipeline

Distributed Transaction to Customer Notification Pipeline

An e-commerce or financial system uses RocketMQ transactional messages to coordinate order placement with OceanBase distributed transactions, then upon successful commit, routes the order confirmation event through EventBridge's API destination to Twilio for reliable multi-channel customer notification (SMS, voice, WhatsApp).

Products involved

Scenario

Use this pipeline when building order-processing or financial systems that require strict consistency between database state changes and customer communications. It ensures notifications are only dispatched after OceanBase distributed transactions successfully commit, leveraging RocketMQ’s two-phase messaging and EventBridge’s API routing to guarantee delivery without manual reconciliation.

Integration steps

  1. Initialize OceanBase Transaction & RocketMQ Half-Message: Start a local transaction (BEGIN;). Send a RocketMQ half-message via Java SDK: producer.sendMessageInTransaction(msg, localExecuter, arg).
  2. Execute Local DB Logic: In executeLocalTransaction(), run OceanBase SQL (INSERT INTO orders...; UPDATE inventory...). Return TransactionStatus.COMMIT on success, ROLLBACK on failure.
  3. Handle Broker Check Callback: Implement checkLocalTransaction() to query OceanBase for transaction state. Return COMMIT if the order exists, else ROLLBACK.
  4. Configure EventBridge API Destination: Create an API Destination targeting https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json. Attach an IAM role with events:InvokeApiDestination and configure Basic Auth using Twilio credentials.
  5. Create EventBridge Rule: Define a rule matching {"source": ["ecommerce.orders"], "detail-type": ["order.confirmed"]}. Set the target to your Twilio API Destination.
  6. Map Payload to Twilio Format: Use an Input Transformer to map RocketMQ fields to Twilio JSON: {"To": "<customer_phone>", "From": "<twilio_number>", "Body": "Order #<order_id> confirmed."}.
  7. Verify Delivery: Monitor EventBridge invocation logs for 201 Created and track MessageSid in Twilio’s dashboard.

Architecture

The app initiates an OceanBase transaction and sends a RocketMQ half-message. Upon DB commit, RocketMQ finalizes the message. EventBridge routes the committed event via an API Destination to Twilio’s REST endpoint, triggering multi-channel dispatch. OceanBase manages state consistency, RocketMQ guarantees transactional delivery, EventBridge decouples routing, and Twilio executes notifications.

Prerequisites

Common pitfalls

Typical questions

FAQ

Q: How does the distributed transaction pipeline coordinate order processing and send customer notifications? A: The pipeline uses RocketMQ transactional messages to coordinate order placement with OceanBase distributed transactions, then routes the confirmed event through EventBridge to Twilio for multi-channel delivery. This architecture ensures reliable order processing by triggering SMS, voice, or WhatsApp alerts only after a successful database commit.