I'm trying to moving data from local folder(file) to ActiveMQ with calling a
process, and ensuring no data lost during network failure or exception throw
by the process. So TRANSACTION comes into my mind. But I can't get it run in
Java DSL. (Spring DSL will be okay strangely.)
public static void main(String[] args) throws Exception {
ActiveMQConnectionFactory mqFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
PooledConnectionFactory mqConnPool = new
PooledConnectionFactory();
mqConnPool.setConnectionFactory(mqFactory);
mqConnPool.setMaxConnections(5);
JmsTransactionManager txnManager = new JmsTransactionManager();
txnManager.setConnectionFactory(mqConnPool);
ActiveMQComponent mqComponent = new ActiveMQComponent();
mqComponent.setConnectionFactory(mqConnPool);
mqComponent.setTransactionManager(txnManager);
mqComponent.setTransacted(true);
mqComponent.setUsePooledConnection(true);
CamelContext context;
context = new DefaultCamelContext();
context.addComponent("activemq",mqComponent);
context.addRoutes(new MyRouteBuilder());
context.start();
while (true)
{
}
}
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("file:c:\\temp\\inbox")
.transacted()
.to("activemq:test")
.process(new Processor() {
public void process(Exchange exchange)
throws Exception {
exchange.setException(new
Exception("abc"));
}
});
}
}
when run the problem, it throws
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at: >>> Policy[ref:null] <<<
from previous post, i found that .transacted() is only work for Spring
Transaction.
is there any other solution to make it "transacted" ??
--
View this message in context:
http://camel.465427.n5.nabble.com/Transaction-configuration-in-Java-DSL-tp4711625p4711625.html
Sent from the Camel - Users mailing list archive at Nabble.com.