@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // create a thread pool builder ThreadPoolBuilder builder = new ThreadPoolBuilder(context); // use thread pool builder to create a custom thread pool ExecutorService myPool = builder.poolSize(5).maxPoolSize(25).maxQueueSize(200).build("MyPool"); from("direct:start") // use our custom pool in the threads DSL .threads().executorService(myPool) .to("log:cool") .to("mock:result") .end(); } }; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // create a custom thread pool ExecutorService lowPool = new ThreadPoolBuilder(context) .poolSize(1).maxPoolSize(5).build("LowPool"); // which we want the WireTap to use from("direct:start") .log("Incoming message ${body}") .wireTap("direct:tap").executorService(lowPool) .to("mock:result"); from("direct:tap") .log("Tapped message ${body}") .to("mock:tap"); } }; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // create a custom thread pool ExecutorService lowPool = new ThreadPoolBuilder(context) .poolSize(1).maxPoolSize(5).build("LowPool"); // which we want the WireTap to use from("direct:start") .log("Incoming message ${body}") .wireTap("direct:tap", lowPool) .to("mock:result"); from("direct:tap") .log("Tapped message ${body}") .to("mock:tap"); } }; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // create shared pool and enlist in registry pool = new ThreadPoolBuilder(context).poolSize(1).buildScheduled(this, "MySharedPool"); registry.put("myPool", pool); from("file:target/a?scheduledExecutorService=#myPool").routeId("a") .to("direct:shared"); from("file:target/b?scheduledExecutorService=#myPool").routeId("b") .to("direct:shared"); from("direct:shared").routeId("shared") .convertBodyTo(String.class) .log("Get ${file:name} using ${threadName}") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getIn().setHeader("threadName", Thread.currentThread().getName()); } }) .to("mock:result"); } }; }
@Override public void configure() throws Exception { ThreadPoolBuilder builder = new ThreadPoolBuilder(getContext()); ExecutorService oneThreadOnly = builder.poolSize(1).maxPoolSize(1) .maxQueueSize(100).build("JustMeDoingTheTapping"); from("direct:start") .wireTap("direct:tapped").executorService(oneThreadOnly) .to("mock:out"); from("direct:tapped") .setHeader("threadName").simple("${threadName}") .to("mock:tapped"); }
@Override public void configure() throws Exception { CamelContext context = getContext(); ExecutorService executorService = new ThreadPoolBuilder(context).poolSize(5).maxQueueSize(100).build("CustomThreadPool"); from("direct:in") .log("Received ${body}:${threadName}") .threads().executorService(executorService) .log("Processing ${body}:${threadName}") .transform(simple("${threadName}")) .to("mock:out"); }