aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorChuanyu Chen <chenchuanyu@huawei.com>2020-02-21 08:46:13 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-21 08:46:13 +0000
commitdca9a2db304b2ac196ec16c1bec08e9df9cd6a22 (patch)
treea696208edcbce1e0312f9536e98c15015ab5eaf8 /mso-api-handlers
parent8017827345ee6d9e3d1015879e191c5fad3a4257 (diff)
parenta2317eb2230ed472040bfff4af26cb126ce9e687 (diff)
Merge "Add method to send message to Camunda engine"
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java19
2 files changed, 23 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 84a80e6617..9944984d33 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -98,6 +98,10 @@
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
index 17377d881a..f30b66c6b5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
@@ -9,9 +9,11 @@ import javax.ws.rs.core.UriBuilder;
import javax.xml.bind.DatatypeConverter;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.json.JSONObject;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.onap.so.utils.CryptoUtils;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,9 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Flux;
@Component
public class CamundaRequestHandler {
@@ -202,6 +207,20 @@ public class CamundaRequestHandler {
return retryTemplate;
}
+ protected void sendCamundaMessages(JSONObject msgJson) {
+ String url = env.getProperty("mso.camundaURL") + "/sobpmnengine/message";
+ HttpHeaders headers =
+ setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+ // Workflow may take a long time so use non-blocking request
+ Flux<String> flux = WebClient.create().post().uri(url).headers(httpHeaders -> {
+ httpHeaders.set(httpHeaders.AUTHORIZATION, headers.get(httpHeaders.AUTHORIZATION).get(0));
+ httpHeaders.set(httpHeaders.ACCEPT, headers.get(httpHeaders.ACCEPT).get(0));
+ httpHeaders.set(httpHeaders.CONTENT_TYPE, headers.get(httpHeaders.CONTENT_TYPE).get(0));
+ }).body(BodyInserters.fromObject(msgJson.toString())).retrieve().bodyToFlux(String.class);
+ flux.subscribe(res -> logger.debug("Send Camunda Message: " + res));
+ }
+
protected RestTemplate getRestTemplate(boolean retry) {
int timeout;
if (retry) {