Functions - lang.transaction

abortResourceManagers

Abort local resource managers.

ballerina/lang.transaction:0.0.1.<init>0
ballerina/lang.transaction:0.0.1.<init>1
cleanupTransactionContext

Cleanup the transaction context.

commitResourceManagers

Commit local resource managers.

createTransactionContext

A new transaction context is created by calling this function.

endTransaction

When a transaction block in Ballerina code ends, it will call this function to end a transaction. Ending a transaction by a participant has no effect because it is the initiator who can decide whether to commit or abort a transaction. Depending on the state of the transaction, the initiator decides to commit or abort the transaction.

getAndClearFailure

Get and Cleanup the failure.

getData
getInfo
getRollbackOnly
info
isTransactional
onCommit
onRollback
prepareResourceManagers

Prepare local resource managers.

rollbackTransaction

Rollback the transaction.

setData
setRollbackOnly
setTransactionContext

Set the transactionContext.

startTransaction

abortResourceManagers

(string transactionId, string transactionBlockId)

returns boolean

Abort local resource managers.

Parameters

  • transactionId string
  • Globally unique transaction ID.

  • transactionBlockId string
  • ID of the transaction block. Each transaction block in a process has a unique ID.

  • Return Type

    (boolean)
  • true or false representing whether the resource manager abortion is successful or not.

ballerina/lang.transaction:0.0.1.<init>0

()

returns error?

ballerina/lang.transaction:0.0.1.<init>1

()

returns error?

cleanupTransactionContext

(string transactionBlockId)

Cleanup the transaction context.

Parameters

  • transactionBlockId string
  • ID of the transaction block.

commitResourceManagers

(string transactionId, string transactionBlockId)

returns boolean

Commit local resource managers.

Parameters

  • transactionId string
  • Globally unique transaction ID.

  • transactionBlockId string
  • ID of the transaction block. Each transaction block in a process has a unique ID.

  • Return Type

    (boolean)
  • true or false representing whether the commit is successful or not.

createTransactionContext

(string coordinationType, string transactionBlockId)

returns TransactionContext | error

A new transaction context is created by calling this function. At this point, a transaction object corresponding to the coordinationType will also be created and stored as an initiated transaction.

Parameters

  • coordinationType string
  • The type of the coordination relevant to the transaction block for which this TransactionContext is being created for.

  • transactionBlockId string
  • The ID of the transaction block.

  • Return Type

    (TransactionContext | error)
  • TransactionContext if the coordination type is valid or an error in case of an invalid coordination type.

endTransaction

(string transactionId, string transactionBlockId)

returns string | Error?

When a transaction block in Ballerina code ends, it will call this function to end a transaction. Ending a transaction by a participant has no effect because it is the initiator who can decide whether to commit or abort a transaction. Depending on the state of the transaction, the initiator decides to commit or abort the transaction.

Parameters

  • transactionId string
  • Globally unique transaction ID.

  • transactionBlockId string
  • ID of the transaction block. Each transaction block in a process has a unique ID.

  • Return Type

    (string | Error?)
  • A string or an error representing the transaction end succcess status or failure respectively.

getAndClearFailure

()

returns boolean

Get and Cleanup the failure.

  • Return Type

    (boolean)
  • is failed.

getData

()

returns readonly
  • Return Type

    (readonly)

getInfo

(byte[] xid)

returns Info?

Parameters

  • xid byte[]
  • Return Type

    (Info?)

getRollbackOnly

()

returns boolean
  • Return Type

    (boolean)

info

()

returns Info
  • Return Type

    (Info)

isTransactional

()

returns boolean
  • Return Type

    (boolean)

onCommit

(CommitHandler handler)

Parameters

  • handler CommitHandler

onRollback

(RollbackHandler handler)

Parameters

  • handler RollbackHandler

prepareResourceManagers

(string transactionId, string transactionBlockId)

returns boolean

Prepare local resource managers.

Parameters

  • transactionId string
  • Globally unique transaction ID.

  • transactionBlockId string
  • ID of the transaction block. Each transaction block in a process has a unique ID.

  • Return Type

    (boolean)
  • true or false representing whether the resource manager preparation is successful or not.

rollbackTransaction

(string transactionBlockId, error? err)

Rollback the transaction.

Parameters

  • transactionBlockId string
  • ID of the transaction block.

  • err error? (default <error?> ())
  • The cause of the rollback.

setData

(readonly e)

Parameters

  • e readonly

setRollbackOnly

(error? e)

Parameters

  • e error?

setTransactionContext

(TransactionContext transactionContext, Info? prevAttempt)

Set the transactionContext.

Parameters

  • prevAttempt Info? (default <ballerina/lang.transaction:0.0.1:Info?> ())
  • Information related to previous attempt.

startTransaction

(string transactionBlockId, Info? prevAttempt)

returns string

Parameters

  • transactionBlockId string
  • prevAttempt Info? (default <ballerina/lang.transaction:0.0.1:Info?> ())
  • Return Type

    (string)