[
https://issues.apache.org/jira/browse/CAMEL-16848?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-16848.
---------------------------------
Assignee: Claus Ibsen
Resolution: Information Provided
> Remove The creation of executorService in JMSConsumer
> -----------------------------------------------------
>
> Key: CAMEL-16848
> URL: https://issues.apache.org/jira/browse/CAMEL-16848
> Project: Camel
> Issue Type: Improvement
> Components: camel-jms
> Affects Versions: 2.25.4
> Environment: Camel 2.23.4
> Centos 7
> Reporter: nizar.ben.mansour
> Assignee: Claus Ibsen
> Priority: Major
> Labels: optimization, performance-benchmark
> Attachments: fixUnusedThreadPoolExecutorInJmsConsumer.diff
>
>
> In JMSConsumer,we have an executorService that's created but used only when
> shutting down and stopping the ListenerContainer.
>
> {code:java}
> protected void stopAndDestroyListenerContainer() {
> if (listenerContainer != null) {
> try {
> listenerContainer.stop();
> listenerContainer.destroy();
> } finally {
> getEndpoint().onListenerContainerStopped(listenerContainer);
> }
> }
> // null container and listener so they are fully re created if this consumer
> is restarted
> // then we will use updated configuration from jms endpoint that may have
> been managed using JMX
> listenerContainer = null;
> messageListener = null;
> initialized = false;
> // shutdown thread pool if listener container was using a private thread pool
> if (shutdownExecutorService && executorService != null) {
>
> getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executorService);
> }
> executorService = null;
> }
> {code}
>
> As per git history,this was created to fix the issue
> https://issues.apache.org/jira/browse/CAMEL-6199
>
> But for our case we are not adding or removing routes dynamiclly and what we
> have remarked is that for each JMS_CONSUMER ,we are creating a
> newCashedThreadPool for no reason:
>
> {code:java}
> else if ((listenerContainer instanceof DefaultJmsMessageListenerContainer &&
> configuration.getDefaultTaskExecutorType() == null)
> || !(listenerContainer instanceof DefaultJmsMessageListenerContainer)) {
> // preserve backwards compatibility if an explicit Default TaskExecutor Type
> was not set;
> // otherwise, defer the creation of the TaskExecutor
> // use a cached pool as DefaultMessageListenerContainer will throttle pool
> sizing
> ExecutorService executor =
> getCamelContext().getExecutorServiceManager().newCachedThreadPool(consumer,
> consumerName);
> setContainerTaskExecutor(listenerContainer, executor);
> // we created a new private thread pool that this listener container is
> using, now store a reference on the consumer
> // so when the consumer is stopped we can shutdown the thread pool also, to
> ensure all resources is shutdown
> consumer.setListenerContainerExecutorService(executor, true);{code}
>
> This threadPoolExecutor that is passed to the JMS_CONSUMER is making a
> performance impact in our application .
> Can we remove it and /or make it configurable so we can desactive it ?
>
> Thanks.
>
> Nizar
--
This message was sent by Atlassian Jira
(v8.3.4#803005)