diff --git a/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeClientConfiguration.java b/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeClientConfiguration.java index 790a416..2f090c9 100644 --- a/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeClientConfiguration.java +++ b/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeClientConfiguration.java @@ -1,6 +1,8 @@ package org.mifos.connector.gsma.zeebe; import io.zeebe.client.ZeebeClient; +import io.zeebe.client.impl.oauth.OAuthCredentialsProvider; +import io.zeebe.client.impl.oauth.OAuthCredentialsProviderBuilder; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,11 +16,27 @@ public class ZeebeClientConfiguration { @Value("${zeebe.client.max-execution-threads}") private int zeebeClientMaxThreads; + @Value("${zeebe.broker.audience}") + private String zeebeAudience; + + @Value("${zeebe.broker.clientId}") + private String zeebeClientId; + + @Value("${zeebe.broker.clientSecret}") + private String zeebeClientSecret; + @Bean public ZeebeClient setup() { + OAuthCredentialsProvider cred = new OAuthCredentialsProviderBuilder() + .audience(zeebeAudience) + .clientId(zeebeClientId) + .clientSecret(zeebeClientSecret) + .build(); + return ZeebeClient.newClientBuilder() .brokerContactPoint(zeebeBrokerContactpoint) - .usePlaintext() + .credentialsProvider(cred) +// .usePlaintext() .numJobWorkerExecutionThreads(zeebeClientMaxThreads) .build(); } diff --git a/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeProcessStarter.java b/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeProcessStarter.java index 553cf6f..e1d8d0b 100644 --- a/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeProcessStarter.java +++ b/src/main/java/org/mifos/connector/gsma/zeebe/ZeebeProcessStarter.java @@ -42,15 +42,16 @@ public static void camelHeadersToZeebeVariables(Exchange exchange, Map> variablesLambda) { - Map variables = new HashMap<>(); - variables.put(CamelProperties.ORIGIN_DATE, Instant.now().toEpochMilli()); - variablesLambda.accept(variables); + public void startZeebeWorkflow(String workflowId) { + // TODO: Uncomment and transform Zeebe variables as per our usecases +// Map variables = new HashMap<>(); +// variables.put(CamelProperties.ORIGIN_DATE, Instant.now().toEpochMilli()); +// variablesLambda.accept(variables); zeebeClient.newCreateInstanceCommand() .bpmnProcessId(workflowId) .latestVersion() - .variables(variables) +// .variables(variables) .send() .join(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index da3a6f5..b11a0b3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -17,6 +17,9 @@ zeebe: evenly-allocated-max-jobs: "#{${zeebe.client.max-execution-threads} / ${zeebe.client.number-of-workers}}" broker: contactpoint: "4ae8d42c-5f02-4e18-b4d4-f4d3d92fc824.zeebe.camunda.io:443" + audience: "4ae8d42c-5f02-4e18-b4d4-f4d3d92fc824.zeebe.camunda.io" + clientId: "ruU.ptno_wct_PXW~ngW4Pp0A0QWw.E1" + clientSecret: "is20pecUw4p_9s3DakWcayYPdDn.GhWfmkm7jtznSErP.ed1iR.z.Qg97EBVz~Pc" gsma: auth: