summaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-02-07 17:14:39 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-02-07 17:19:04 -0500
commitd0ec4426cbe4da7dbf94a4faf6e36c032a81c395 (patch)
tree80dad5b6047dda91c0272aab40d5fc576070ac2c /common/src/main
parent6db24e72ecbf4f5c63085085c10dc656568b563b (diff)
Initial commit to check client alive
Initial commit to check client alive Issue-ID: SO-2653 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ib9f4cf7f5815bd9b8d0d42417f3e5fd83382547a
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
index e43b431821..4f13cec8f4 100644
--- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
+++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
@@ -1,6 +1,8 @@
package org.onap.so.utils;
import java.security.GeneralSecurityException;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.camunda.bpm.client.ExternalTaskClient;
import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
@@ -8,21 +10,30 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+
+
@Component
public class ExternalTaskServiceUtils {
@Autowired
public Environment env;
+ protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
+
+
private static final Logger logger = LoggerFactory.getLogger(ExternalTaskServiceUtils.class);
public ExternalTaskClient createExternalTaskClient() throws Exception {
String auth = getAuth();
ClientRequestInterceptor interceptor = createClientInterceptor(auth);
- return ExternalTaskClient.create().baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1)
- .addInterceptor(interceptor).asyncResponseTimeout(120000).build();
+ ExternalTaskClient client =
+ ExternalTaskClient.create().baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1)
+ .addInterceptor(interceptor).asyncResponseTimeout(120000).build();
+ taskClients.add(client);
+ return client;
}
protected ClientRequestInterceptor createClientInterceptor(String auth) {
@@ -42,5 +53,13 @@ public class ExternalTaskServiceUtils {
return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "3"));
}
+ @Scheduled(fixedDelay = 30000)
+ public void checkAllClientsActive() {
+ getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start);
+ }
+
+ protected Set<ExternalTaskClient> getClients() {
+ return taskClients;
+ }
}