1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 package org.oran.otf.camunda.configuration;
\r
19 import org.oran.otf.camunda.configuration.listener.OTFJobExecutorStartingEventListener;
\r
20 import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
\r
21 import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration;
\r
22 import org.camunda.bpm.spring.boot.starter.configuration.impl.DefaultJobConfiguration;
\r
23 import org.camunda.bpm.spring.boot.starter.event.JobExecutorStartingEventListener;
\r
24 import org.springframework.beans.factory.annotation.Autowired;
\r
25 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
\r
26 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
\r
27 import org.springframework.context.annotation.Bean;
\r
28 import org.springframework.context.annotation.Configuration;
\r
29 import org.springframework.context.annotation.Primary;
\r
32 public class OTFJobConfiguration extends DefaultJobConfiguration {
\r
33 @Autowired protected JobExecutor jobExecutor;
\r
36 protected void configureJobExecutor(SpringProcessEngineConfiguration configuration) {
\r
38 String[] hostnameSplit = {"0", "0", "0"};
\r
41 String hostname = System.getenv("HOSTNAME");
\r
42 hostnameSplit = hostname.split("-");
\r
43 podNumber = Integer.parseInt(hostnameSplit[2]);
\r
44 } catch (Exception e) {
\r
48 //if (podNumber == 1) {
\r
49 camundaBpmProperties.getJobExecution().setLockTimeInMillis(43200000);
\r
50 camundaBpmProperties.getJobExecution().setBackoffTimeInMillis(90);
\r
51 camundaBpmProperties.getJobExecution().setMaxBackoff(450L);
\r
52 camundaBpmProperties.getJobExecution().setWaitIncreaseFactor(2f);
\r
54 super.configureJobExecutor(configuration);
\r
56 configuration.getJobExecutor().setLockTimeInMillis(43200000);
\r
57 configuration.getJobExecutor().setBackoffTimeInMillis(90);
\r
58 configuration.getJobExecutor().setMaxBackoff(450L);
\r
59 configuration.getJobExecutor().setWaitIncreaseFactor(2);
\r
62 // configuration.getJobExecutor().setAutoActivate(false);
\r
68 @ConditionalOnProperty(prefix = "camunda.bpm.job-execution", name = "enabled", havingValue = "true", matchIfMissing = true)
\r
69 @ConditionalOnBean(JobExecutor.class)
\r
70 public static JobExecutorStartingEventListener jobExecutorStartingEventListener() {
\r
71 return new OTFJobExecutorStartingEventListener();
\r