Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SETUP] Zeebe connection #4

Merged
merged 3 commits into from Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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;
Expand All @@ -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();
}
Expand Down
Expand Up @@ -42,15 +42,16 @@ public static void camelHeadersToZeebeVariables(Exchange exchange, Map<String, O
}
}

public void startZeebeWorkflow(String workflowId, Consumer<Map<String, Object>> variablesLambda) {
Map<String, Object> 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<String, Object> 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();

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Expand Up @@ -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:
Expand Down