-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAMEL-12418: High CPU load on events watching #2283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have code that shutdown that executor service - also the executor service should be created via Camel's API for that, see ExecutorServiceManager you can get via CamelContext
Ok, i'll fix it |
@Gr1f0n6x let us know how it goes for you |
@davsclaus, I tried to use Sorry for delay. I had some problems with building the project |
} | ||
|
||
@Override | ||
protected Runnable createWatcher(EventClient client) throws Exception { | ||
return new EventWatcher(client); | ||
} | ||
|
||
@Override | ||
protected void doStop() throws Exception { | ||
scheduledExecutorService.shutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gr1f0n6x , please use ExecutorServiceManager.shutdownGraceful there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmvolod, did it. Thank you for hint, didn't notice this method before
|
||
public ConsulEventConsumer(ConsulEndpoint endpoint, ConsulConfiguration configuration, Processor processor) { | ||
super(endpoint, configuration, processor, Consul::eventClient); | ||
this.executorServiceManager = endpoint.getCamelContext().getExecutorServiceManager(); | ||
this.scheduledExecutorService = this.executorServiceManager.newSingleThreadScheduledExecutor(this, "ConsulEventConsumer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We create these in the doStart method, so we have start/stop logic together, and the constructors are light-weight
* Add delay between listEvents requests * Use ExecutorServiceManager got via CamelContext * Add explicit field executorServiceManager * Use ExecutorServiceManager.shutdownGraceful
* Add delay between listEvents requests * Use ExecutorServiceManager got via CamelContext * Add explicit field executorServiceManager * Use ExecutorServiceManager.shutdownGraceful
I believe that scheduledExecutorService with schedule method will be a little better then Thread.sleep(mills) (maybe i'm wrong).
Also, i didn't add default value as proposed in description of this problem because as i found in
ConsulClientConfiguration
the default value ofblockSeconds
is 10:Check style
Result of
mvn clean install -Psourcecheck
: