Yes I did.  It is in fact the basis for my solution 😃

Right now, I’m doing some fakery ….

Taking the Spring JTATransactionManager (which extends 
AbstractTransactionManager which implements javax…TransactionManager) and 
wrapping it with an implementation of TransactionManager where the 
implementation stubs delegate to JTATransactionManager.

The WrappedTransactionManager is then added to the ignite configuration.

I hate this solution.

Please tell me there is a better way.

SCott

From: Ilya Kasnacheev <[email protected]>
Sent: Wednesday, March 27, 2019 8:19 AM
To: [email protected]
Subject: Re: xa transaction manager and ignite

Hello!

Never done that, but did you go through 
https://apacheignite.readme.io/docs/transactions#section-integration-with-jta ?

Regards,
--
Ilya Kasnacheev


пн, 25 мар. 2019 г. в 21:49, Scott Cote <[email protected]<mailto:[email protected]>>:
Igniters:

I’m unsuccessfully establishing an XA transaction manager to associate with my 
ignite configuration.

I don’t know the JNDI name location of my java transaction manager (not to be 
confused with the spring transaction manager which implements 
TransactionManagerPlatform).

Here is a snippet of my code (with pieces omitted for brevity):

…

import javax.cache.configuration.Factory;
import javax.transaction.TransactionManager;

import org.apache.ignite.configuration.TransactionConfiguration;

import org.apache.ignite.cache.jta.jndi.CacheJndiTmFactory;
…

@Autowired(required = false)
TransactionManager transactionManager;

…

private TransactionConfiguration doTransactionConfiguration() {
    TransactionConfiguration configuration = new TransactionConfiguration();

    if (null == transactionManager) {
        CacheJndiTmFactory txManagerFactory = new CacheJndiTmFactory();
        // see 
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-jta.html
 for these names
        String[] jndiNames = 
{"java:comp/UserTransaction","java:comp/TransactionManager","java:/TransactionManager"};
        txManagerFactory.setJndiNames(jndiNames);
        configuration.setTxManagerFactory(txManagerFactory);
    } else {

        Factory<TransactionManager> txManagerFactory = new 
Factory<TransactionManager>() {
            @Override
            public TransactionManager create() {
                return jtaTransactionManager();
            }
        };

        configuration.setTxManagerFactory(txManagerFactory);

    }
    return configuration;
}

private TransactionManager jtaTransactionManager() {
    return transactionManager;
}





public IgniteConfiguration doit() {

    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setTransactionConfiguration(doTransactionConfiguration());

    return cfg;

}

Here is a snippet of my code (with pieces omitted for brevity):
When I execute the public method “do it”, the autowire fails to load (I do not 
require it) and none of the jndi locations that I listed seem to have the “java 
TransactionManager” (again – not to be confused with the bean named 
“TransactionManager” that does not implement TransactionManager, but instead 
implements TransactionManagerPlatform).

What is the right way to associate the xa manager that is setup with spring – 
which I don’t know in advance, with ignite?

Thanks,

SCott

Reply via email to