Skip to content

Commit

Permalink
refactor(camunda-client): replace zeebe-client by camunda-client (#3826)
Browse files Browse the repository at this point in the history
* refactor(camunda-client): 1st commit, further investigation needed merging

* refactor(camunda-client): fixing the issue, refactor is done

* refactor(camunda-client) bring a single camunda version

* refactor(camunda-client) bring a single camunda version 5

* refactor(camunda-client) bring a single camunda version 6

* Update connectors/http/rest/README.peb

Co-authored-by: Jonathan <[email protected]>

---------

Co-authored-by: Jonathan <[email protected]>
(cherry picked from commit 611bcfe)
  • Loading branch information
mathias-vandaele authored and johnBgood committed Jan 10, 2025
1 parent 70c7f4d commit 49e0540
Show file tree
Hide file tree
Showing 84 changed files with 390 additions and 340 deletions.
30 changes: 17 additions & 13 deletions connector-runtime/connector-runtime-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
A collection of runtime utilities to wrap Connector functions as job workers and handle Connector discovery.
This artifact can be used to build custom Connector runtimes.
If you are looking for a ready-to-use Connector runtime, refer to the
[Spring Connector Runtime](../connector-runtime-spring) or a corresponding [Spring Boot starter](../spring-boot-starter-camunda-connectors).
[Spring Connector Runtime](../connector-runtime-spring) or a
corresponding [Spring Boot starter](../spring-boot-starter-camunda-connectors).

## Wrapping a Connector function

Expand All @@ -12,32 +13,33 @@ Include the job worker runtime utilities as maven dependency:
```xml

<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-runtime-core</artifactId>
<version>${version.connectors}</version>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-runtime-core</artifactId>
<version>${version.connectors}</version>
</dependency>
```

You can create a job worker by wrapping a Connector function like this:

```java
import io.camunda.client.CamundaClient;
import io.camunda.connector.slack.outbound.SlackFunction;
import io.camunda.connector.runtime.jobworker.api.outbound.ConnectorJobHandler;
import io.camunda.zeebe.client.ZeebeClient;

public class Main {

public static void main(String[] args) {
public static void main(String[] args) {

var zeebeClient = ZeebeClient.newClientBuilder().build();
var camundaClient = CamundaClient.newClientBuilder().build();

zeebeClient.newWorker()
.jobType("slack")
.handler(new ConnectorJobHandler(new SlackFunction()))
.name("SLACK")
.fetchVariables("foo", "bar")
.open();
}
camundaClient.newWorker()
.jobType("slack")
.handler(new ConnectorJobHandler(new SlackFunction()))
.name("SLACK")
.fetchVariables("foo", "bar")
.open();
}
}
```

Expand All @@ -54,6 +56,7 @@ variables and with SPI. Only one configuration approach must be used per applica
### Discovery via environment variables

Outbound Connector configuration example:

```
CONNECTOR_SLACK_FUNCTION=io.camunda.connector.runtime.util.outbound.SlackFunction
CONNECTOR_SLACK_TYPE=io.camunda.connector:SLACK
Expand All @@ -62,6 +65,7 @@ CONNECTOR_SLACK_TIMEOUT=10000 # optional
```

Inbound Connector configuration example:

```
CONNECTOR_KAFKA_SUBSCRIPTION_EXECUTABLE=io.camunda.connector.runtime.util.outbound.KafkaSubscription
CONNECTOR_KAFKA_SUBSCRIPTION_TYPE=io.camunda.connector:KAFKA_SUBSCRIPTION
Expand Down
3 changes: 2 additions & 1 deletion connector-runtime/connector-runtime-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@

<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-client-java</artifactId>
<artifactId>camunda-client-java</artifactId>
<version>${version.camunda}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.client.api.search.response.FlowNodeInstance;
import io.camunda.connector.api.inbound.ProcessInstanceContext;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.feel.jackson.FeelContextAwareObjectReader;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.validation.ValidationUtil;
import io.camunda.zeebe.client.api.search.response.FlowNodeInstance;
import java.util.Map;
import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package io.camunda.connector.runtime.core.inbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.client.api.search.response.FlowNodeInstance;
import io.camunda.connector.api.inbound.*;
import io.camunda.connector.api.validation.ValidationProvider;
import io.camunda.connector.runtime.core.inbound.correlation.InboundCorrelationHandler;
import io.camunda.connector.runtime.core.inbound.correlation.MessageCorrelationPoint.BoundaryEventCorrelationPoint;
import io.camunda.document.Document;
import io.camunda.document.store.DocumentCreationRequest;
import io.camunda.zeebe.client.api.search.response.FlowNodeInstance;
import java.util.List;
import java.util.Map;
import java.util.Queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.camunda.connector.runtime.core.inbound;

import io.camunda.zeebe.client.api.search.response.FlowNodeInstance;
import io.camunda.client.api.search.response.FlowNodeInstance;
import java.util.List;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*/
package io.camunda.connector.runtime.core.inbound.correlation;

import io.camunda.client.CamundaClient;
import io.camunda.client.api.command.ClientStatusException;
import io.camunda.client.api.response.ProcessInstanceEvent;
import io.camunda.client.api.response.PublishMessageResponse;
import io.camunda.connector.api.error.ConnectorInputException;
import io.camunda.connector.api.inbound.ActivationCheckResult;
import io.camunda.connector.api.inbound.CorrelationResult;
Expand All @@ -29,10 +33,6 @@
import io.camunda.connector.runtime.core.ConnectorHelper;
import io.camunda.connector.runtime.core.inbound.InboundConnectorElement;
import io.camunda.connector.runtime.core.inbound.ProcessElementContextFactory;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.command.ClientStatusException;
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import io.camunda.zeebe.client.api.response.PublishMessageResponse;
import io.grpc.Status;
import java.time.Duration;
import java.util.List;
Expand All @@ -46,19 +46,19 @@ public class InboundCorrelationHandler {

private static final Logger LOG = LoggerFactory.getLogger(InboundCorrelationHandler.class);

private final ZeebeClient zeebeClient;
private final CamundaClient camundaClient;
private final FeelEngineWrapper feelEngine;

private final ProcessElementContextFactory processElementContextFactory;

private final Duration defaultMessageTtl;

public InboundCorrelationHandler(
ZeebeClient zeebeClient,
CamundaClient camundaClient,
FeelEngineWrapper feelEngine,
ProcessElementContextFactory processElementContextFactory,
Duration defaultMessageTtl) {
this.zeebeClient = zeebeClient;
this.camundaClient = camundaClient;
this.feelEngine = feelEngine;
this.processElementContextFactory = processElementContextFactory;
this.defaultMessageTtl = defaultMessageTtl;
Expand Down Expand Up @@ -118,7 +118,7 @@ protected CorrelationResult triggerStartEvent(

try {
ProcessInstanceEvent result =
zeebeClient
camundaClient
.newCreateInstanceCommand()
.bpmnProcessId(correlationPoint.bpmnProcessId())
.version(correlationPoint.version())
Expand Down Expand Up @@ -204,7 +204,7 @@ private CorrelationResult publishMessage(
CorrelationResult result;
try {
var command =
zeebeClient
camundaClient
.newPublishMessageCommand()
.messageName(messageName)
.correlationKey(correlationKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.camunda.connector.runtime.core.outbound;

import io.camunda.client.api.response.ActivatedJob;
import io.camunda.connector.api.outbound.JobContext;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import java.util.Map;
import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
package io.camunda.connector.runtime.core.outbound;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.client.api.command.FinalCommandStep;
import io.camunda.client.api.response.ActivatedJob;
import io.camunda.client.api.response.CompleteJobResponse;
import io.camunda.client.api.response.FailJobResponse;
import io.camunda.client.api.worker.JobClient;
import io.camunda.client.api.worker.JobHandler;
import io.camunda.connector.api.error.ConnectorException;
import io.camunda.connector.api.error.ConnectorRetryException;
import io.camunda.connector.api.outbound.OutboundConnectorFunction;
Expand All @@ -34,12 +40,6 @@
import io.camunda.connector.runtime.core.secret.SecretProviderAggregator;
import io.camunda.connector.runtime.core.secret.SecretProviderDiscovery;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.zeebe.client.api.command.FinalCommandStep;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.response.CompleteJobResponse;
import io.camunda.zeebe.client.api.response.FailJobResponse;
import io.camunda.zeebe.client.api.worker.JobClient;
import io.camunda.zeebe.client.api.worker.JobHandler;
import java.time.Duration;
import java.time.format.DateTimeParseException;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.*;
import io.camunda.client.api.response.ActivatedJob;
import io.camunda.connector.api.error.ConnectorException;
import io.camunda.connector.api.outbound.JobContext;
import io.camunda.connector.api.outbound.OutboundConnectorContext;
Expand All @@ -32,7 +33,6 @@
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.DocumentCreationRequest;
import io.camunda.document.store.InMemoryDocumentStore;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Loading

0 comments on commit 49e0540

Please sign in to comment.