-
1. Re: Threading in Router??
davsclaus Oct 26, 2009 11:30 AM (in response to sriram_imshriram)The multicast can work either in parallel or sequential mode AFAIR.
In sequential it uses the same thread as the caller. In parallel it uses a new task for each step in the multicast. You use enable the parallel using parallelProcessing option on it.
It uses the ExecutorService that has been configured it. There is a default configuration which uses a pool of 10 threads.
In Camel 2.2 we have on the roadmap for easy thread pool configuration.
There are tickets in JIRA about this.
You can now in Camel 2.0 configure this manually using the setExecutorService methods.
If you use the wireTap DSL then it uses a new task for the tapped exchange.
-
2. Re: Threading in Router??
sriram_imshriram Oct 27, 2009 11:50 AM (in response to davsclaus)I havent used ExecutorService before. Can you please throw some light on it? Is there any sample available to guide us on it?
Also is it available only for Camel 2.0+?
-
3. Re: Threading in Router??
davsclaus Oct 27, 2009 12:24 PM (in response to sriram_imshriram)No its also part of Camel 1.x
You can read about it as its part of JDK itself. So do a bit of googling and check the javadoc.
-
4. Re: Threading in Router??
njiang Oct 27, 2009 8:42 PM (in response to sriram_imshriram)Here is the dsl which is taken from loan_broker_example
// Router 1 to call the bank endpoints sequentially
from(Constants.LOANBROKER_URI)
// Using the CreditScoreProcessor to call the credit agency service
.process(new CreditScoreProcessor(Constants.CREDITAGENCY_ADDRESS))
// Set the aggregation strategy on the multicast pattern
.multicast(new BankResponseAggregationStrategy())
// Send out the request to three different banks sequentially
.to(Constants.BANK1_URI, Constants.BANK2_URI, Constants.BANK3_URI);
// Router 2 to call the bank endpoints in parallel
from(Constants.PARALLEL_LOANBROKER_URI)
.process(new CreditScoreProcessor(Constants.CREDITAGENCY_ADDRESS))
// Using the thread pool to send out messages to three different banks in parallel
.multicast(new BankResponseAggregationStrategy())
// Camel will create a thread pool with the default size (10)
// for sending the message in parallel
.parallelProcessing()
.to(Constants.BANK1_URI, Constants.BANK2_URI, Constants.BANK3_URI);
-
5. Re: Threading in Router??
davaleri Nov 3, 2009 2:40 PM (in response to davsclaus)It is part of Camel 1.x; however, the default executor is fairly restrictive. This is the default executor that gets created in the MultiCastProcessor:
this.executor = new ThreadPoolExecutor(processors.size(), processors.size(), 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1000));
from("seda:inputParallelEndpoint?concurrentConsumers=5")
.multicast()
.parallelProcessing()
.executor(pool)
.to("mock:a", "mock:b", "bean:delayer")
.to("mock:c");
-
6. Re: Threading in Router??
davsclaus Nov 4, 2009 12:12 AM (in response to davaleri)Ah well spotted.
Do you mind creating a ticket in JIRA?
-