use of org.apache.camel.spring.spi.SpringTransactionPolicy in project camel by apache.
the class TransactionalClientDataSourceAsyncTest method createRouteBuilder.
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");
}
};
}
use of org.apache.camel.spring.spi.SpringTransactionPolicy in project camel by apache.
the class TransactionalClientDataSourceWithOnExceptionHandledAndRollbackTest method createRouteBuilder.
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");
}
};
}
use of org.apache.camel.spring.spi.SpringTransactionPolicy in project camel by apache.
the class TransactionalClientDataSourceWithOnExceptionRollbackTest method createRouteBuilder.
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");
}
};
}
use of org.apache.camel.spring.spi.SpringTransactionPolicy in project camel by apache.
the class TransactionalClientDataSourceWithOnExceptionTest method createRouteBuilder.
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");
}
};
}
Aggregations