return new XATransactionRouteBuilder();
}
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
// JMS setup
ActiveMQXAConnectionFactory xaConnectionFactory =
new ActiveMQXAConnectionFactory();
xaConnectionFactory.setBrokerURL(broker.getTcpConnectorUri());
registry.put("connectionFactory", xaConnectionFactory);
atomikosConnectionFactoryBean = new AtomikosConnectionFactoryBean();
atomikosConnectionFactoryBean.setXaConnectionFactory(xaConnectionFactory);
atomikosConnectionFactoryBean.setUniqueResourceName("xa.activemq");
atomikosConnectionFactoryBean.setMaxPoolSize(10);
atomikosConnectionFactoryBean.setIgnoreSessionTransactedFlag(false);
registry.put("atomikos.connectionFactory", atomikosConnectionFactoryBean);
// JDBC setup
JdbcDataSource jdbcDataSource = EmbeddedDataSourceFactory.getJdbcDataSource("sql/schema.sql");
AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean();
atomikosDataSourceBean.setXaDataSource(jdbcDataSource);
atomikosDataSourceBean.setUniqueResourceName("xa.h2");
registry.put("atomikos.dataSource", atomikosDataSourceBean);
// Atomikos setup
userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
userTransactionManager.init();
UserTransactionImp userTransactionImp = new UserTransactionImp();
userTransactionImp.setTransactionTimeout(300);
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
jtaTransactionManager.setTransactionManager(userTransactionManager);
jtaTransactionManager.setUserTransaction(userTransactionImp);
registry.put("jta.transactionManager", jtaTransactionManager);
SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
propagationRequired.setTransactionManager(jtaTransactionManager);
propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED", propagationRequired);
auditLogDao = new AuditLogDao(jdbcDataSource);
CamelContext camelContext = new DefaultCamelContext(registry);