Optimize Plugin System

Optimize allows you adapt the behavior of Optimize, e.g. to decide which kind of data should be analyzed and to tackle technical issues.

Have a look at the Optimize Examples Repository to see some use cases for the plugin system and how plugins can be implemented and used.

Setup your environment

First, add the Optimize plugin to your project via maven:

<dependency>
  <groupId>org.camunda.optimize</groupId>
  <artifactId>plugin</artifactId>
  <version>3.1.0</version>
</dependency>

Note: It is important to use the same plugin environment version as the Optimize version you plan to use. Optimize rejects plugins that are built with different Optimize versions to avoid compatibility problems. This also means that to upgrade to newer Optimize versions it is necessary to build the plugin again with the new version.

To tell maven where to find the plugin environment, add the following repository to your project:

<repositories>
  <repository>
    <id>camunda-bpm-nexus</id>
    <name>camunda-bpm-nexus</name>
    <url>
      https://app.camunda.com/nexus/content/repositories/camunda-optimize
    </url>
  </repository>
</repositories>

Please note: to make this work, you need to add your nexus credentials and the server to your settings.xml.

It is required to create a uber jar so that Optimize can load third-party dependencies and to validate the used Optimize version. You can add the following to your project:

 <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <finalName>${project.artifactId}</finalName>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Note: Optimize loads plugin classes isolated from the ones used in Optimize by default. This allows to use different library versions for the plugin to the ones used in Optimize.

In the case of when you want to use the provided Optimize dependencies instead it is possible to exclude them from the uber jar by setting the scope of those dependencies to provided. Then Optimize does not load them from the plugin. This might have side-effects if the used version in the plugin is different to the one provided by Optimize. To get an overview, what is already provided by Optimize, have a look at the third party libraries.

Debug your plugin

To start optimize in debug mode, just execute the optimize start with a debug parameter.

On Unix systems this could look like the following

  • for the demo distribution:
./optimize-demo.sh debug
  • for the production distribution:
./optimize-startup.sh debug

On a Windows system this could look like the following

  • for the demo distribution:
.\optimize-demo.bat debug
  • for the production distribution:
.\optimize-startup.bat debug

By default this will open up a debug port on 9999. Once you have set this up, you need to open the project where you implemented the plugin in your favorite IDE. Then connect to the debug port:

To change the default debug port, have a look into the optimize-startup.sh on Linux and optimize-startup.bat on Windows system. There you should find a variable called DEBUG_PORT, where you can customize the port.