aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java32
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java2
2 files changed, 29 insertions, 5 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
index e8e4b85cae..ace6e1937d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -101,7 +101,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
try {
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables));
processor.startProcess(processKey, variableMap);
- WorkflowResponse response = waitForResponse(getRequestId(inputVariables));
+ WorkflowResponse response = waitForResponse(inputVariables);
return Response.status(202).entity(response).build();
} catch (WorkflowProcessorException e) {
WorkflowResponse response = e.getWorkflowResponse();
@@ -112,9 +112,12 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
}
}
- private WorkflowResponse waitForResponse(String requestId) throws Exception {
+ private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception {
+ String requestId = getRequestId(inputVariables);
long currentWaitTime = 0;
- while (DEFAULT_WAIT_TIME > currentWaitTime) {
+ long waitTime = getWaitTime(inputVariables);
+ logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime);
+ while (waitTime > currentWaitTime) {
Thread.sleep(workflowPollInterval);
currentWaitTime = currentWaitTime + workflowPollInterval;
WorkflowContext foundContext = contextHolder.getWorkflowContext(requestId);
@@ -123,7 +126,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
return buildResponse(foundContext);
}
}
- throw new Exception("TimeOutOccured");
+ throw new Exception("TimeOutOccured in WorkflowAsyncResource.waitForResponse for time " + waitTime + "ms");
}
private WorkflowResponse buildUnkownError(String requestId, String error) {
@@ -171,4 +174,25 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
return inputVariables;
}
+ /**
+ * Returns the wait time, this is used by the resource on how long it should wait to send a response If none
+ * specified DEFAULT_WAIT_TIME is used
+ *
+ * @param inputVariables
+ * @return
+ */
+ private long getWaitTime(Map<String, Object> inputVariables) {
+ String timeout = inputVariables.get("mso-service-request-timeout") == null ? null
+ : inputVariables.get("mso-service-request-timeout").toString();
+
+ if (timeout != null) {
+ try {
+ return Long.parseLong(timeout) * 1000;
+ } catch (NumberFormatException nex) {
+ logger.debug("Invalid input for mso-service-request-timeout");
+ }
+ }
+ return DEFAULT_WAIT_TIME;
+ }
+
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
index 20f3eb4fee..bcc3739c32 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java
@@ -116,7 +116,7 @@ public class WorkflowResource extends ProcessEngineAwareService {
long timeToWaitAfterProcessEnded = uriInfo == null ? 5000 : 60000;
AtomicLong timeProcessEnded = new AtomicLong(0);
boolean endedWithNoResponse = false;
-
+ logger.debug(LOGMARKER + "WorkflowResource.startProcessInstanceByKey using timeout: " + waitTime);
while (now <= endTime) {
Thread.sleep(pollingInterval);