is NEW_QUEUE a jms queue? If so you can use concurrentConsumers /
maxConcurrentConsumers for concurrency. And see also the asyncConsumer
option.

Read this page, about these options, and check also for concurrency
http://camel.apache.org/jms



On Wed, Feb 26, 2014 at 7:39 AM, Rural Hunter <ruralhun...@gmail.com> wrote:
> Hi,
>
> I implemented this but I'm facing severe performance problem. My legacy
> application handles this by separated threads and the performance is more
> than 10 times of my Camel application. I don't know if it's my Camel
> application problem or it's the problem of Camel. Here the detail of my
> application:
>
> My Route:
> from(NEW_QUEUE).threads(threadNum).unmarshal().json(JsonLibrary.Gson,
> IndexDoc.class)
> .process(processor1)
> .process(processor2)
> .process(processor3)
> .process(processor4)
> .process(processor5)
> .process(processor6).wireTap(MY_COMP_URL)
> .marshal().json(JsonLibrary.Gson).to(INDEX_QUEUE);
>
> My CamelContext Settings:
> int threadNum=20;
> int maxThreadNum=50;
> CamelContext context = new DefaultCamelContext();
> ThreadPoolProfile
> threadPool=context.getExecutorServiceManager().getDefaultThreadPoolProfile();
> threadPool.setPoolSize(threadNum);
> threadPool.setMaxPoolSize(maxThreadNum);
> context.setStreamCaching(true);
>
> //context.addComponent("jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
> String mqServer=ConfigSupport.getConfig("mq_server");
>
> ActiveMQConfiguration config = new ActiveMQConfiguration();
> config.setBrokerURL(mqServer);
> config.setUsePooledConnection(true);
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory(mqServer);
> // optimize AMQ to be as fast as possible so unit testing is quicker
> connectionFactory.setCopyMessageOnSend(false);
> connectionFactory.setOptimizeAcknowledge(true);
> connectionFactory.setOptimizedMessageDispatch(true);
> // use a pooled connection factory
> PooledConnectionFactory pooled = new
> PooledConnectionFactory(connectionFactory);
> pooled.setMaxConnections(maxThreadNum);
> config.setConnectionFactory(pooled);
>
> context.addComponent("activemq", new ActiveMQComponent(config));
>
> Is there any problem in above code? My legacy application uses 10 threads
> and the route logic is exactly same. I even increased the threadNum of my
> Camel application to 50 and max to 100 but there is no obvious improvement.
>
>
>
> 于 2014/2/21 17:18, Henryk Konsek 写道:
>>
>> You can use ThreadLocal to cache the instance of your library per
>>
>> thread in the processor.
>>
>> private ThreadLocal<NonThreadSafeExpensiveToCreateUtil> util =
>> new ThreadLocal<NonThreadSafeExpensiveToCreateUtil>() {
>>          @Override public NonThreadSafeExpensiveToCreateUtil
>> initialValue() {
>>              return new NonThreadSafeExpensiveToCreateUtil();
>>          }
>>      };
>>
>> As Camel uses pool of threads, it will keep a single instance of the
>> util bound to each thread executing the processor.
>>
>> Cheers.
>>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Reply via email to