[ 
https://issues.apache.org/jira/browse/CAMEL-12418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16440603#comment-16440603
 ] 

ASF GitHub Bot commented on CAMEL-12418:
----------------------------------------

dmvolod commented on a change in pull request #2283: CAMEL-12418: High CPU load 
on events watching
URL: https://github.com/apache/camel/pull/2283#discussion_r181994251
 
 

 ##########
 File path: 
components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java
 ##########
 @@ -33,32 +36,46 @@
 import org.apache.camel.component.consul.ConsulEndpoint;
 
 public final class ConsulEventConsumer extends 
AbstractConsulConsumer<EventClient> {
+    private ScheduledExecutorService scheduledExecutorService;
 
     public ConsulEventConsumer(ConsulEndpoint endpoint, ConsulConfiguration 
configuration, Processor processor) {
         super(endpoint, configuration, processor, Consul::eventClient);
+        this.scheduledExecutorService = 
endpoint.getCamelContext().getExecutorServiceManager().newSingleThreadScheduledExecutor(this,
 "ConsulEventConsumer");
     }
 
     @Override
     protected Runnable createWatcher(EventClient client) throws Exception {
         return new EventWatcher(client);
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        scheduledExecutorService.shutdown();
 
 Review comment:
   @Gr1f0n6x , please use ExecutorServiceManager.shutdownGraceful there

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> camel-consul - High CPU load on events watching
> -----------------------------------------------
>
>                 Key: CAMEL-12418
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12418
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-consul
>    Affects Versions: 2.21.0
>            Reporter: Viachaslau Tsikhanovich
>            Priority: Major
>             Fix For: 2.22.0
>
>
> Camel-Consul library expects EventClient to block requests and [passes number 
> of seconds to block request to 
> EventClient|https://github.com/apache/camel/blob/camel-2.21.0/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/ConsulEventConsumer.java#L59].
>  However Event HTTP Endpoint [does not support Blocking 
> Queries|https://www.consul.io/api/event.html] and EventClient [ignores passed 
> queryOptions|https://github.com/rickfast/consul-client/blob/1.1.1/src/main/java/com/orbitz/consul/EventClient.java#L164].
>  This results in high CPU usage because ConsulEventConsumer constantly makes 
> requests to Consul without any delay or blocking.
>  Maybe some _Thread.sleep_ could be added to _EventWatcher.watch(EventClient 
> client)_ before _client.listEvents_ call or any other fix to introduce delay 
> between _listEvents_ requests.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to