Hazelcast C++ Client
Public Types | Public Member Functions | List of all members
hazelcast::client::transaction_options Class Reference

Contains the configuration for a Hazelcast transaction. More...

#include <transaction_options.h>

Public Types

enum  transaction_type { TWO_PHASE = 1, LOCAL = 2 }
 Transaction type.
 

Public Member Functions

 transaction_options ()
 Creates a new default configured TransactionsOptions. More...
 
transaction_type get_transaction_type () const
 
transaction_optionsset_transaction_type (transaction_type transaction_type)
 Sets the TransactionType. More...
 
std::chrono::milliseconds get_timeout () const
 
transaction_optionsset_timeout (std::chrono::milliseconds duration)
 The timeout determines the maximum lifespan of a transaction. More...
 
int get_durability () const
 
transaction_optionsset_durability (int num_machines)
 Sets the transaction durability. More...
 

Detailed Description

Contains the configuration for a Hazelcast transaction.

Constructor & Destructor Documentation

◆ transaction_options()

hazelcast::client::transaction_options::transaction_options ( )

Creates a new default configured TransactionsOptions.

It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE.

Member Function Documentation

◆ get_durability()

int hazelcast::client::transaction_options::get_durability ( ) const
Returns
the transaction durability.
See also
#setDurability(int)

◆ get_timeout()

std::chrono::milliseconds hazelcast::client::transaction_options::get_timeout ( ) const
Returns
the timeout

◆ get_transaction_type()

transaction_options::transaction_type hazelcast::client::transaction_options::get_transaction_type ( ) const
Returns
the TransactionType.

◆ set_durability()

transaction_options & hazelcast::client::transaction_options::set_durability ( int  num_machines)

Sets the transaction durability.

The durability is the number of machines that can take over if a member fails during a transaction commit or rollback. This value only has meaning when TransactionType::TWO_PHASE is selected.

Parameters
durabilitythe durability
Returns
the updated TransactionOptions.
Exceptions
illegal_argumentif durability smaller than 0.

◆ set_timeout()

transaction_options & hazelcast::client::transaction_options::set_timeout ( std::chrono::milliseconds  duration)

The timeout determines the maximum lifespan of a transaction.

So if a transaction is configured with a timeout of 2 minutes, then it will automatically rollback if it hasn't committed yet.

Parameters
timeoutInSecondsthe timeout value.
Returns
the updated TransactionOptions
Exceptions
illegal_argumentif timeout smaller or equal than 0, or timeUnit is null.
See also
#getTimeout()

◆ set_transaction_type()

transaction_options & hazelcast::client::transaction_options::set_transaction_type ( transaction_type  transaction_type)

Sets the TransactionType.

A local transaction is less safe than a two phase transaction; when a member fails during the commit of a local transaction, it could be that some of the changes are committed, while others are not and this can leave your system in an inconsistent state.

Parameters
transactionTypethe new TransactionType.
Returns
the updated TransactionOptions.
See also
#getTransactionType()
#setDurability(int)

The documentation for this class was generated from the following files: