With the optional dependency camunda-connect, the process engine supports simpleconnectors. Currently the following connector implementations exist:

Connector ID
REST HTTP http-connector
SOAP HTTP soap-http-connector

Configure Camunda Connect

As Camunda Connect is an optional dependency, it is not immediately available when using the process engine. With a pre-built distribution, Camunda Connect is already preconfigured.

The following connect artifacts exist:

  • camunda-connect-core: a jar that contains only the core Connect classes. In addition to camunda-connect-core, single connector implementations like camunda-connect-http-client and camunda-connect-soap-http-client exist. These dependencies should be used when the default connectors have to be reconfigured or when custom connector implementations are used.
  • camunda-connect-connectors-all: a single jar without dependencies that contains the HTTP and SOAP connectors.
  • camunda-engine-plugin-connect: a process engine plugin to add Connect to the Camunda BPM platform.

    Maven Coordinates

Please import the Camunda BOM to ensure correct versions for every Camunda project.

camunda-connect-core

camunda-connect-core contains the core classes of Connect. Additionally, the HTTP and SOAP connectors can be added with the dependencies camunda-connect-http-client and camunda-connect-soap-http-client. These artifacts will transitively pull in their dependencies, like Apache HTTP client. For integration with the engine, the artifact camunda-engine-plugin-connect is needed. Given that the BOM is imported, the Maven coordinates are as follows:

  1. <dependency>
  2. <groupId>org.camunda.connect</groupId>
  3. <artifactId>camunda-connect-core</artifactId>
  4. </dependency>
  1. <dependency>
  2. <groupId>org.camunda.connect</groupId>
  3. <artifactId>camunda-connect-http-client</artifactId>
  4. </dependency>
  1. <dependency>
  2. <groupId>org.camunda.connect</groupId>
  3. <artifactId>camunda-connect-soap-http-client</artifactId>
  4. </dependency>
  1. <dependency>
  2. <groupId>org.camunda.bpm</groupId>
  3. <artifactId>camunda-engine-plugin-connect</artifactId>
  4. </dependency>

camunda-connect-connectors-all

This artifact contains the HTTP and SOAP connectors as well as their dependencies. To avoid conflicts with other versions of these dependencies, the dependencies are relocated to different packages. camunda-connect-connectors-all has the following Maven coordinates:

  1. <dependency>
  2. <groupId>org.camunda.connect</groupId>
  3. <artifactId>camunda-connect-connectors-all</artifactId>
  4. </dependency>

Configure the Process Engine Plugin

camunda-engine-plugin-connect contains a class called org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin that can be registered with a process engine using the plugin mechanism. For example, a bpm-platform.xml file with the plugin enabled would look as follows:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <bpm-platform xmlns="http://www.camunda.org/schema/1.0/BpmPlatform"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.camunda.org/schema/1.0/BpmPlatform http://www.camunda.org/schema/1.0/BpmPlatform ">
  5. ...
  6. <process-engine name="default">
  7. ...
  8. <plugins>
  9. <plugin>
  10. <class>org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin</class>
  11. </plugin>
  12. </plugins>
  13. ...
  14. </process-engine>
  15. </bpm-platform>

When using a pre-built distribution of Camunda BPM, the plugin is already pre-configured.

Use Connectors

To use a connector, you have to add the Camunda extension element connector. The connector is configured by a unique connectorId, which specifies the used connector implementation. The ids of the currently supported connectors can be found at the beginning of this section. Additionally, an input/output mapping is used to configure the connector. The required input parameters and the available output parameters depend on the connector implementation. Additional input parameters can also be provided to be used within the connector.

As an example, a shortened configuration of the Camunda SOAP connector implementation is shown. A complete example can be found in the Camunda examples repository on GitHub.

  1. <serviceTask id="soapRequest" name="Simple SOAP Request">
  2. <extensionElements>
  3. <camunda:connector>
  4. <camunda:connectorId>soap-http-connector</camunda:connectorId>
  5. <camunda:inputOutput>
  6. <camunda:inputParameter name="url">
  7. http://example.com/webservice
  8. </camunda:inputParameter>
  9. <camunda:inputParameter name="payload">
  10. <![CDATA[
  11. <soap:Envelope ...>
  12. ... // the request envelope
  13. </soap:Envelope>
  14. ]]>
  15. </camunda:inputParameter>
  16. <camunda:outputParameter name="result">
  17. <![CDATA[
  18. ... // process response body
  19. ]]>
  20. </camunda:outputParameter>
  21. </camunda:inputOutput>
  22. </camunda:connector>
  23. </extensionElements>
  24. </serviceTask>

A full example of the REST connector can also be found in the Camunda examples repository on GitHub.

原文: https://docs.camunda.org/manual/7.9/user-guide/process-engine/connectors/