Apache Ignite 2.16 - c++ support for Transactions for a dynamically created cache using thin client

32 views Asked by At

Hello ApacheIgnite Team,

I am planning to create a dynamic cache using c++ thin client and would like to use the transactions for some operations. Is there a provision in c++ thin client to set the cache configuration with Automicity mode to transactional ?

ignite::thin::IgniteClientConfiguration cfg;
cfg.SetEndPoints("10.1.53.61:10800");
cfg.SetPartitionAwareness(true);
m_igniteClient = ignite::thin::IgniteClient::Start(cfg);
ignite::thin::cache::CacheClient<int16_t, std::string> client =
    m_igniteClient.GetOrCreateCache<int16_t, std::string>(cacheName.c_str());

IgniteClientConfiguration or ignite::thin::IgniteClient does not have any API to set the Automicity Mode.

Please note that the caches are getting created dyanmically using the thin client c++.

Is there any alternative way to achieve transactions using thin client c++?

1

There are 1 answers

1
Pavel Tupitsyn On

You can define a Cache Template [1] on the server and use it to dynamically create caches from the C++ thin client

  1. Use a cache config with asterisk * on the server - the cache won't be started, but a template will be created
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="cacheConfiguration">
        <list>
            <bean abstract="true" class="org.apache.ignite.configuration.CacheConfiguration" id="cache-template-bean">
                <!-- when you create a template via XML configuration, you must add an asterisk to the name of the template -->
                <property name="name" value="tx-cache-*"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <!-- Other cache parameters -->
            </bean>
        </list>
    </property>
</bean>
  1. Start a cache with a corresponding name prefix in C++
// Create transactional cache from template
auto cache = m_igniteClient.GetOrCreateCache<int16_t, std::string>(
    "tx-cache-foobar1");

[1] https://ignite.apache.org/docs/latest/configuring-caches/configuration-overview#cache-templates