Java 类org.apache.camel.spring.spi.SpringTransactionPolicy 实例源码

项目:camel-cookbook-examples    文件:JmsTransactionRequestReplyTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    ActiveMQConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory("vm://embedded?broker.persistent=false");
    registry.put("connectionFactory", connectionFactory);

    JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
    jmsTransactionManager.setConnectionFactory(connectionFactory);
    registry.put("jmsTransactionManager", jmsTransactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(jmsTransactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    SpringTransactionPolicy propagationNotSupported = new SpringTransactionPolicy();
    propagationNotSupported.setTransactionManager(jmsTransactionManager);
    propagationNotSupported.setPropagationBehaviorName("PROPAGATION_NOT_SUPPORTED");
    registry.put("PROPAGATION_NOT_SUPPORTED", propagationNotSupported);

    CamelContext camelContext = new DefaultCamelContext(registry);

    ActiveMQComponent activeMQComponent = new ActiveMQComponent();
    activeMQComponent.setConnectionFactory(connectionFactory);
    activeMQComponent.setTransactionManager(jmsTransactionManager);
    camelContext.addComponent("jms", activeMQComponent);

    return camelContext;
}
项目:Camel    文件:QueueToQueueTransactionTest.java   
@Test
public void testRollbackUsingXmlQueueToQueue() throws Exception {

    // configure routes and add to camel context
    context.addRoutes(new SpringRouteBuilder() {

        @Override
        public void configure() throws Exception {
            Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);
            from("activemq:queue:foo?transacted=true").policy(required).process(new ConditionalExceptionProcessor())
                .to("activemq:queue:bar?transacted=true");
        }
    });

    assertResult();
}
项目:Camel    文件:SqlTransactedRouteTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry reg = super.createRegistry();

    db = new EmbeddedDatabaseBuilder()
        .setType(EmbeddedDatabaseType.DERBY).build();
    reg.bind("testdb", db);

    DataSourceTransactionManager txMgr = new DataSourceTransactionManager();
    txMgr.setDataSource(db);
    reg.bind("txManager", txMgr);

    SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
    txPolicy.setTransactionManager(txMgr);
    txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    reg.bind("required", txPolicy);

    return reg;
}
项目:Camel    文件:TransactionalClientDataSourceWithOnExceptionRollbackTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            // on exception is also supported
            onException(IllegalArgumentException.class).handled(false).to("mock:error").rollback();

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
项目:Camel    文件:TransactionalClientDataSourceWithOnExceptionHandledAndRollbackTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            onException(IllegalArgumentException.class)
                    .handled(true).to("mock:error").rollback();

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
项目:Camel    文件:TransactionalClientWithRollbackTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    // Notice that we use the SpringRouteBuilder that has a few more features than
    // the standard RouteBuilder
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // setup the transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // use transaction error handler
            errorHandler(transactionErrorHandler(required));

            // must setup policy for each route
            from("direct:okay").policy(required)
                    .setBody(constant("Tiger in Action")).bean("bookService")
                    .setBody(constant("Elephant in Action")).bean("bookService");

            // must setup policy for each route
            from("direct:fail").policy(required)
                    .setBody(constant("Tiger in Action")).bean("bookService")
                    // force a rollback
                    .rollback();
        }
    };
}
项目:Camel    文件:TransactionalClientDataSourceWithOnExceptionTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            // on exception is also supported
            onException(IllegalArgumentException.class).handled(false).to("mock:error");

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
项目:Camel    文件:DataSourceSpringRouteBuilder.java   
public void configure() throws Exception {
    // get the required policy
    SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

    // For spring based transaction, end users are encouraged to use the
    // transaction error handler instead of the default DeadLetterChannel.
    errorHandler(transactionErrorHandler(required));

    // set the required policy for this route
    from("direct:okay").policy(required).
        setBody(constant("Tiger in Action")).bean("bookService").
        setBody(constant("Elephant in Action")).bean("bookService");

    // set the required policy for this route
    from("direct:fail").policy(required).
        setBody(constant("Tiger in Action")).bean("bookService").
        setBody(constant("Donkey in Action")).bean("bookService");
}
项目:camel-cookbook-examples    文件:TransactionPolicyTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    dataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
    registry.put("transactionManager", transactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(transactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    auditLogDao = new AuditLogDao(dataSource);
    messageDao = new MessageDao(dataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(dataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:JmsTransactionTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    ActiveMQConnectionFactory connectionFactory =
        new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(broker.getTcpConnectorUri());
    registry.put("connectionFactory", connectionFactory);

    JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
    jmsTransactionManager.setConnectionFactory(connectionFactory);
    registry.put("jmsTransactionManager", jmsTransactionManager);

    SpringTransactionPolicy policy = new SpringTransactionPolicy();
    policy.setTransactionManager(jmsTransactionManager);
    policy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", policy);

    CamelContext camelContext = new DefaultCamelContext(registry);

    ActiveMQComponent activeMQComponent = new ActiveMQComponent();
    activeMQComponent.setConnectionFactory(connectionFactory);
    activeMQComponent.setTransactionManager(jmsTransactionManager);
    camelContext.addComponent("jms", activeMQComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:RollbackMarkRollbackOnlyTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    DataSource auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource);
    registry.put("transactionManager", transactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(transactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    auditLogDao = new AuditLogDao(auditDataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(auditDataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:RollbackTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    DataSource auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource);
    registry.put("transactionManager", transactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(transactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    auditLogDao = new AuditLogDao(auditDataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(auditDataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:DatabaseTransactionTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");
    //registry.put("auditDataSource", auditDataSource);

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource);
    registry.put("transactionManager", transactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(transactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    auditLogDao = new AuditLogDao(auditDataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(auditDataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:Camel    文件:QueueToProcessorTransactionTest.java   
@Test
public void testRollbackUsingXmlQueueToProcessor() throws Exception {

    // configure routes and add to camel context
    context.addRoutes(new SpringRouteBuilder() {

        @Override
        public void configure() throws Exception {
            Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);
            from("activemq:queue:foo").policy(required).process(new ConditionalExceptionProcessor());
        }
    });

    assertResult();
}
项目:Camel    文件:QueueToQueueRequestReplyTransactionTest.java   
@Test
public void testRollbackUsingXmlQueueToQueueRequestReplyUsingDynamicMessageSelector() throws Exception {
    final ConditionalExceptionProcessor cp = new ConditionalExceptionProcessor(5);
    context.addRoutes(new SpringRouteBuilder() {
        @Override
        public void configure() throws Exception {
            Policy required = lookup("PROPAGATION_REQUIRED_POLICY", SpringTransactionPolicy.class);

            from("activemq:queue:foo").policy(required).process(cp).to("activemq-1:queue:bar?replyTo=queue:bar.reply");

            from("activemq-1:queue:bar").process(new Processor() {
                public void process(Exchange e) {
                    String request = e.getIn().getBody(String.class);
                    Message out = e.getOut();
                    String selectorValue = e.getIn().getHeader("camelProvider", String.class);
                    if (selectorValue != null) {
                        out.setHeader("camelProvider", selectorValue);
                    }
                    out.setBody("Re: " + request);
                }
            });
        }
    });

    for (int i = 0; i < 5; ++i) {
        Object reply = template.requestBody("activemq:queue:foo", "blah" + i);
        assertTrue("Received unexpeced reply", reply.equals("Re: blah" + i));
        assertTrue(cp.getErrorMessage(), cp.getErrorMessage() == null);
    }
}
项目:Camel    文件:TransactionalClientDataSourceAsyncTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new SpringRouteBuilder() {
        public void configure() throws Exception {

            context.addComponent("async", new MyAsyncComponent());

            // use required as transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // configure to use transaction error handler and pass on the required as it will fetch
            // the transaction manager from it that it needs
            errorHandler(transactionErrorHandler(required));

            // on exception is also supported
            onException(IllegalArgumentException.class).handled(false).to("mock:error");

            from("direct:okay")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .log("Before thread ${threadName}")
                .to("async:bye:camel")
                .log("After thread ${threadName}")
                .setBody(constant("Elephant in Action")).bean("bookService");

            from("direct:fail")
                .policy(required)
                .setBody(constant("Tiger in Action")).bean("bookService")
                .log("Before thread ${threadName}")
                .to("async:bye:camel")
                .log("After thread ${threadName}")
                .setBody(constant("Donkey in Action")).bean("bookService");
        }
    };
}
项目:Camel    文件:TransactionalClientDataSourceLookupTypeTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    // START SNIPPET: e1
    // Notice that we use the SpringRouteBuilder that has a few more features than
    // the standard RouteBuilder
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: e1
            // lookup the transaction policy
            SpringTransactionPolicy required = lookup(SpringTransactionPolicy.class);

            // use this error handler instead of DeadLetterChannel that is the default
            // Notice: transactionErrorHandler is in SpringRouteBuilder
            if (useTransactionErrorHandler) {
                // useTransactionErrorHandler is only used for unit testing to reuse code
                // for doing a 2nd test without this transaction error handler, so ignore
                // this. For spring based transaction, end users are encouraged to use the
                // transaction error handler instead of the default DeadLetterChannel.
                errorHandler(transactionErrorHandler(required));
            }
            // END SNIPPET: e1

            // START SNIPPET: e2
            // set the required policy for this route
            from("direct:okay").policy(required).
                setBody(constant("Tiger in Action")).bean("bookService").
                setBody(constant("Elephant in Action")).bean("bookService");

            // set the required policy for this route
            from("direct:fail").policy(required).
                setBody(constant("Tiger in Action")).bean("bookService").
                setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e2
        }
    };
}
项目:Camel    文件:TransactionalClientDataSourceTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    // START SNIPPET: e1
    // Notice that we use the SpringRouteBuilder that has a few more features than
    // the standard RouteBuilder
    return new SpringRouteBuilder() {
        public void configure() throws Exception {
            // START SNIPPET: e1
            // lookup the transaction policy
            SpringTransactionPolicy required = lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);

            // use this error handler instead of DeadLetterChannel that is the default
            // Notice: transactionErrorHandler is in SpringRouteBuilder
            if (isUseTransactionErrorHandler()) {
                // useTransactionErrorHandler is only used for unit testing to reuse code
                // for doing a 2nd test without this transaction error handler, so ignore
                // this. For spring based transaction, end users are encouraged to use the
                // transaction error handler instead of the default DeadLetterChannel.
                errorHandler(transactionErrorHandler(required));
            }
            // END SNIPPET: e1

            // START SNIPPET: e2
            // set the required policy for this route
            from("direct:okay").policy(required).
                setBody(constant("Tiger in Action")).bean("bookService").
                setBody(constant("Elephant in Action")).bean("bookService");

            // set the required policy for this route
            from("direct:fail").policy(required).
                setBody(constant("Tiger in Action")).bean("bookService").
                setBody(constant("Donkey in Action")).bean("bookService");
            // END SNIPPET: e2
        }
    };
}
项目:switchyard    文件:TransactionHelper.java   
private void addToCamelRegistry() {
    final PlatformTransactionManager transactionManager = TransactionManagerFactory.getInstance().create();
    // Add the transaction manager
    _context.getWritebleRegistry().put(TransactionManagerFactory.TM, transactionManager);
    // Add a policy ref bean pointing to the transaction manager
    _context.getWritebleRegistry().put(CamelConstants.TRANSACTED_REF, new SpringTransactionPolicy(transactionManager));
}
项目:fcrepo-camel    文件:FcrepoTransactionIT.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    final JndiRegistry reg = super.createRegistry();

    txMgr = new FcrepoTransactionManager();
    txMgr.setBaseUrl(FcrepoTestUtils.getFcrepoBaseUrl());
    reg.bind("txManager", txMgr);

    final SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
    txPolicy.setTransactionManager(txMgr);
    txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    reg.bind("required", txPolicy);

    return reg;
}
项目:camel-cookbook-examples    文件:TransactionPolicyNestedTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    dataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
    registry.put("transactionManager", transactionManager);

    {
        SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
        propagationRequired.setTransactionManager(transactionManager);
        propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
        registry.put("PROPAGATION_REQUIRED", propagationRequired);
    }

    {
        SpringTransactionPolicy propagationNotSupported = new SpringTransactionPolicy();
        propagationNotSupported.setTransactionManager(transactionManager);
        propagationNotSupported.setPropagationBehaviorName("PROPAGATION_NOT_SUPPORTED");
        registry.put("PROPAGATION_NOT_SUPPORTED", propagationNotSupported);
    }

    auditLogDao = new AuditLogDao(dataSource);
    messageDao = new MessageDao(dataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(dataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:RollbackMarkRollbackOnlyLastTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    DataSource dataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
    registry.put("transactionManager", transactionManager);

    {
        SpringTransactionPolicy propagationRequiresNew = new SpringTransactionPolicy();
        propagationRequiresNew.setTransactionManager(transactionManager);
        propagationRequiresNew.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW");
        registry.put("PROPAGATION_REQUIRES_NEW", propagationRequiresNew);
    }

    {
        SpringTransactionPolicy propagationRequiresNew2 = new SpringTransactionPolicy();
        propagationRequiresNew2.setTransactionManager(transactionManager);
        propagationRequiresNew2.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW");
        registry.put("PROPAGATION_REQUIRES_NEW-2", propagationRequiresNew2);
    }

    auditLogDao = new AuditLogDao(dataSource);
    messageDao = new MessageDao(dataSource);

    CamelContext camelContext = new DefaultCamelContext(registry);

    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(dataSource);
    camelContext.addComponent("sql", sqlComponent);

    return camelContext;
}
项目:camel-cookbook-examples    文件:IdempotentConsumerInTransactionTest.java   
@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");
    registry.put("auditDataSource", auditDataSource);

    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource);
    registry.put("transactionManager", transactionManager);

    SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
    propagationRequired.setTransactionManager(transactionManager);
    propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
    registry.put("PROPAGATION_REQUIRED", propagationRequired);

    auditLogDao = new AuditLogDao(auditDataSource);

    TransactionTemplate transactionTemplate = new TransactionTemplate();
    transactionTemplate.setTransactionManager(transactionManager);
    transactionTemplate.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW");

    idempotentRepository = new JdbcMessageIdRepository(auditDataSource, transactionTemplate, "ws");

    CamelContext camelContext = new DefaultCamelContext(registry);
    SqlComponent sqlComponent = new SqlComponent();
    sqlComponent.setDataSource(auditDataSource);
    camelContext.addComponent("sql", sqlComponent);
    return camelContext;
}
项目:wildfly-camel    文件:TransactedJMSIntegrationTest.java   
@Before
public void setUp() throws Exception {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
    TransactionTemplate template = new TransactionTemplate(jtaTransactionManager, new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));

    SpringTransactionPolicy transactionPolicy = new SpringTransactionPolicy();
    transactionPolicy.setTransactionTemplate(template);
    transactionPolicy.setTransactionManager(jtaTransactionManager);

    initialctx.bind("PROPAGATION_REQUIRED", transactionPolicy);
    initialctx.bind("transactionManager", jtaTransactionManager);

    jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, jtaTransactionManager);
}
项目:switchyard    文件:InboundHandlerTestBase.java   
protected void mockTransaction(String manager) {
    PlatformTransactionManager transactionManager = Mockito.mock(PlatformTransactionManager.class);
    _camelContext.getWritebleRegistry().put(manager, transactionManager);
    _camelContext.getWritebleRegistry().put(CamelConstants.TRANSACTED_REF, new SpringTransactionPolicy(transactionManager));
}
项目:Camel    文件:SpringRouteBuilder.java   
/**
 * Creates a transaction error handler.
 *
 * @param policy   using this transaction policy (eg: required, supports, ...)
 * @return the created error handler
 */
public TransactionErrorHandlerBuilder transactionErrorHandler(SpringTransactionPolicy policy) {
    return transactionErrorHandler(policy.getTransactionTemplate());
}