use of org.apache.camel.processor.async.MyAsyncComponent in project camel by apache.
the class AsyncLoopCopyTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
context.addComponent("async", new MyAsyncComponent());
from("direct:start").to(// Should receive Hello Camel
"mock:before").to("log:before").process(new Processor() {
public void process(Exchange exchange) throws Exception {
beforeThreadName = Thread.currentThread().getName();
}
}).loop(header("NumberIterations")).copy().to(// Should receive 2x Hello Camel
"mock:loopIterationStart").to(// Will transform the body to Bye Camel
"async:bye:camel").to(// Should receive 2x Bye Camel
"mock:loopIterationEnd").end().process(new Processor() {
public void process(Exchange exchange) throws Exception {
afterThreadName = Thread.currentThread().getName();
}
}).to("log:after").to(// Should receive 1x Hello Camel (original message)
"mock:result");
}
};
}
use of org.apache.camel.processor.async.MyAsyncComponent in project camel by apache.
the class AsyncLoopTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() {
final Processor loopTest = new LoopTestProcessor(10);
return new RouteBuilder() {
public void configure() {
context.addComponent("async", new MyAsyncComponent());
from("direct:a").loop(8).to("async:hello:camel?append=true").to("mock:result");
from("direct:b").loop(header("loop")).to("async:hello:camel?append=true").to("mock:result");
from("direct:c").loop().xpath("/Hello/@n").to("async:hello:camel?append=true").to("mock:result");
from("direct:d").loop(2).to("async:hello:camel?append=true").to("mock:result").end().to("mock:last");
from("direct:e").loop(10).to("async:hello:camel?append=true").process(loopTest).to("mock:result").end().to("mock:last");
}
};
}
use of org.apache.camel.processor.async.MyAsyncComponent in project camel by apache.
the class EnricherAsyncUnhandledExceptionTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ShutdownStrategy shutdownStrategy = camelContext.getShutdownStrategy();
camelContext.addComponent("async", new MyAsyncComponent());
shutdownStrategy.setTimeout(1000);
shutdownStrategy.setTimeUnit(TimeUnit.MILLISECONDS);
shutdownStrategy.setShutdownNowOnTimeout(true);
return camelContext;
}
use of org.apache.camel.processor.async.MyAsyncComponent 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.processor.async.MyAsyncComponent in project camel by apache.
the class EnricherSendEventTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ShutdownStrategy shutdownStrategy = camelContext.getShutdownStrategy();
camelContext.addComponent("async", new MyAsyncComponent());
shutdownStrategy.setTimeout(1000);
shutdownStrategy.setTimeUnit(TimeUnit.MILLISECONDS);
shutdownStrategy.setShutdownNowOnTimeout(true);
ManagementStrategy managementStrategy = new DefaultManagementStrategy();
managementStrategy.addEventNotifier(en);
camelContext.setManagementStrategy(managementStrategy);
return camelContext;
}
Aggregations