Exploring iOS App Development: Simplifying the Process
WSO2Con USA Microservices Transactions
1. Senior Director - Platform Architecture,
WSO2
Managing Transactions in Your
Microservices Architecture
Afkham Azeez
2. What is a distributed transaction?
ORACLE
M
MySQL
M
Oracle DB
Instance
MySQL DB
Instance
Queue
Remove Message
Insert Record
Insert Record
Resource ManagersGlobal Transaction
3. Why do we need it?
Debit $1000
FROM Jack’s
Account
Start Start
Success Success
Success Failed
Transaction
Boundary
Debit $1000
FROM Jack’s
Account
Credit $1000
TO Tom’s
Account
Credit $1000
TO Tom’s
Account
Transaction
Complete
We are in
Trouble
Action: Jack’s doing a bank
transfer of $1000 from his
account to Tom’s
4. Monolith - multiple modules in the
same process
Microservices - modules running in different
processes
The problem
12. Agreement protocols & coordination types
● Joint outcome is negotiated at the end of interactions
● Negotiation rules and how to determine outcome is referred
to as an agreement protocol
● Collection of agreement protocols is called a coordination
type
16. 2PC Coordination Protocols
● Completion
○ Used by participants that control the end of a transaction by an
explicit commit or abort command
● Durable
○ Used by participants that manipulate persistent resources
● Volatile
○ Used by participants that only need to get a notification that the
voting phase of the 2PC has started
○ e.g. microservices that cache data which need to flush data before
transaction ends
27. ● A coordination type
● Participant will register compensation endpoint with
coordinator
● Compensations pairs
○ Endpoints which can participate in transactions will declare
compensation actions
Compensation
28. Transactions sidecar
Bridging to existing runtime transactions
Spring Boot
Participant
Txn Sidecar
Initiator
Participant
Participant
Spring Txn
29. service<http:Service> InitiatorService bind listener {
hiInitiator (endpoint caller, http:Request req) {
// This is how you initiate a transaction
transaction with retries =2 {
// Calling a remote participant
http:Response res =
check participant->get(“/ParticipantService/hi”)
} onretry {
// Code here will execute before retrying
} committed {
// Code here will execute after the initiated transaction
// has committed
} aborted {
// Code here will execute after the initiated transaction
// has been aborted
}
}
Ballerina example
Initiator
30. service<http:Service> ParticipantService bind listener {
@transactions:participant {
oncommit = onTxnCommit,
onabort = onTxnAbort
}
hi(endpoint caller, http:Request req) {
// Transactional code goes here. If there are transaction
// aware stuff such as SQL connectors etc. they will
// be registered as resources affected by this transaction
// This local function call on the remote participant will
// result in the function registering with the initiator
// as a remote participant
remoteParticipantDoSomething();
}
}
Ballerina example
Participant