transaction
ballerinai/transaction
Module Overview
This module provides the Ballerina transaction manager implementation.
Functions
beginTransaction
function beginTransaction(string? transactionId, string transactionBlockId, string registerAtUrl, string coordinationType) returns TransactionContext|error
When a transaction block in Ballerina code begins, it will call this function to begin a transaction. If this is a new transaction (transactionId == () ), then this instance will become the initiator and will create a new transaction context. If the participant and initiator are in the same process, this transaction block will register with the local initiator via a local function call. If the participant and initiator are in different processes, this transaction block will register with the remote initiator via a network call.
Parameters
- transactionId string? - Globally unique transaction ID. If this is a new transaction which is initiated, then this will be null. If this is a participant in an existing transaction, then it will have a value.
- transactionBlockId string - ID of the transaction block. Each transaction block in a process has a unique ID.
- registerAtUrl string - The URL of the initiator
- coordinationType string - Coordination type of this transaction
Return Type
- TransactionContext|error - Newly created/existing TransactionContext for this transaction.
Records
transaction: RemoteProtocol
This represents the protocol associated with the coordination type.
Fields
- name string(default "") - protocol name
- url string(default "") - protocol URL. This URL will have a value only if the participant is remote. If the participant is local,
the
protocolFn
will be called
transaction: TransactionContext
Fields
- contextVersion string(default "1.0") -
- transactionId string(default "") -
- transactionBlockId string(default "") -
- coordinationType string(default "") -
- registerAtURL string(default "") -
transaction: TransactionParticipantConfig
Contains the configurations for local transaction participant function.
Fields
- oncommit
function(string) ()
? - Function to execute when transaction committed.
- onabort
function(string) ()
? - Function to execute when transaction aborted.
Constants
Annotations
transaction: Participant
The annotation which is used to configure local transaction participant function.