A Connector template for new C8 outbound connector
To use this template update the following resources to match the name of your connector:
- README (title, description)
- POM (artifact name, id, description)
- Connector (rename, implement, update
OutboundConnectorannotation)- Service Provider Interface (SPI) ( adapt to your connector class)
- Element Template (will be generated during build)
about creating Connectors
Check out the Connectors SDK
Camunda Outbound Connector Template
This repository provides a template for creating a Camunda Outbound Connector using the Connector SDK. The example is using the annotations-based approach that allows to define multiple operations within a single Connector.
Example implementation: io.camunda.example.MyConnector.
This example leverages the @Operation annotation to define multiple operations within a single Connector class.
The example defines two operations - echo and addTwoNumbers - each represented by a method annotated with @Operation.
Each operation method accepts an input parameter annotated with @Variable (or @Header) and returns an output object.
The runtime uses the OutboundConnectorProvider interface to discover and instantiate the Connector. If you rename your
Connector class, make sure to update the corresponding entry in the META-INF/services/io.camunda.connector.api.outbound.OutboundConnectorProvider file.
Another example implementation for an annotations-based Connector is the CSV Connector.
You can package the Connector by running the following command:
mvn clean packageThis will create the following artifacts:
- A thin JAR without dependencies.
- A fat JAR containing all dependencies, potentially shaded to avoid classpath conflicts. This will not include the SDK
artifacts since those are in scope
providedand will be brought along by the respective Connector Runtime executing the Connector.
You can use the maven-shade-plugin defined in the Maven configuration to relocate common dependencies
that are used in other Connectors and
the Connector Runtime.
This helps to avoid classpath conflicts when the Connector is executed.
For example, without shading, you might encounter errors like:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.setserializationInclusion(Lcom/fasterxml/jackson/annotation/JsonInclude$Include;)Lcom/fasterxml/jackson/databind/ObjectMapper;
This occurs when your connector and the runtime use different versions of the same library (e.g., Jackson).
Use the relocations configuration in the Maven Shade plugin to define the dependencies that should be shaded.
The Maven Shade documentation
provides more details on relocations.
| Name | Description | Example | Notes |
|---|---|---|---|
| user | Mock username | alice |
Has no effect on the function call outcome. |
| token | Mock token value | my-secret-token |
Has no effect on the function call outcome. |
| message | Mock message | Hello World |
Echoed back in the output. If starts with 'fail', an error will be thrown. |
{
"result":{
"myProperty":"Message received: ..."
}
}| Code | Description |
|---|---|
| FAIL | Message starts with 'fail' (ignoring case) |
Run unit tests
mvn clean verifyYou can run the unit and integration tests by executing the following Maven command:
mvn clean verifyYou will need the following tools installed on your machine:
-
Camunda Modeler, which is available in two variants:
- Desktop Modeler for a local installation.
- Web Modeler for an online experience.
-
Docker, which is required to run the Camunda platform.
The Connectors Runtime requires a running Camunda platform to interact with. To set up a local Camunda environment, follow these steps:
- Clone the Camunda distributions repository from GitHub and navigate to the Camunda 8.8 docker-compose directory:
git clone [email protected]:camunda/camunda-distributions.git
cd cd docker-compose/versions/camunda-8.8Note: This template is compatible with Camunda 8.8. Using other versions may lead to compatibility issues.
Either comment out the connectors service, or use the --scale flag to exclude it:
docker compose -f docker-compose-core.yaml up --scale connectors=0Add the element-templates/my-connector.json to your Modeler configuration as per
the Element Templates documentation.
Then, to use your connector in a local Camunda environment, follow these steps:
- Run the
io.camunda.example.LocalConnectorRuntimeto start your connector for testing purposes. - Open the Camunda Desktop Modeler and create a new BPMN diagram.
- Design a process that incorporates your newly created connector.
- Deploy the process to your local Camunda platform.
- Verify that the process is running smoothly by accessing Camunda Operate at localhost:8088/operate. Username and password are both
demo.
The Connectors Runtime (LocalConnectorRuntime) requires connection details to interact with your Camunda SaaS cluster. To set this up, follow these steps:
- Navigate to Camunda SaaS.
- Create a cluster using the latest version available.
- Select your cluster, then go to the
APIsection and clickCreate new Client. - Ensure the
zeebecheckbox is selected, then clickCreate. - Copy the configuration details displayed under the
Spring Boottab. - Paste the copied configuration into your
application.propertiesfile within your project.
- Start your connector by executing
io.camunda.example.LocalConnectorRuntimein your development environment. - Access the Web Modeler and create a new project.
- Click on
Create new, then selectUpload files. Upload the connector template from the repository you have. - After uploading, publish the connector template by clicking the Publish button.
- In the same folder, create a new BPMN diagram.
- Design and start a process that incorporates your new connector.
The element template for this sample connector is generated automatically based on the connector input class using the Element Template Generator.
The generation is embedded in the Maven build and can be triggered by running mvn clean package.
The generated element template can be found in element-templates/my-connector.json.