Skip to main content

Create Plugin

Dependencies

Rill Flow plugins must be written in Java because Rill Flow are running under jdk 17 version.

In the Rill Flow project, the rill-flow-plugins module contains examples of module development, you can use the code of the submodule in the rill-flow-plugins module to start your plugin development trip, and you can also refer to the Open Source Project Code and Example:PF4J.

First, you need to add dependencies to your plugin item:

<dependency>
<groupId>com.weibo.api.video.task</groupId>
<artifactId>rill-flow-interfaces</artifactId>
</dependency>

code

Then create a plugin class in the plugin project, and implement Dispatcher Extensionary Interface:

import org.pf4j.Extension;
import com.rill.flow.interfaces.dispatcher.DispatcherExtension;

@Extension
public class UserDefineDispatcherExtension implements DispatcherExtension {
@Override
public String handle(Resource resource, DispatchInfo dispatchInfo) {
return null;
}

@Override
public String getName() {
return "user_define";
}
}

Pack and run

According to PF4J protocol, create a META-INF directory in the resources of the plugin, and fill out the basic contents of the plugin in the MANIFEST.MF such as:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: decebal
Build-Jdk: 17.0.8
Plugin-Id: user-plugin
Plugin-Provider: rill-flow
Plugin-Version: 0.0.1

Add building information: in pom.xml

<build>
<finalName>user-plugin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.artifactId}-${project.version}-all</finalName>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Plugin-Id>aliyun-ai-plugin</Plugin-Id>
<Plugin-Version>1.0</Plugin-Version>
<Plugin-Provider>rill-flow</Plugin-Provider>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<annotationProcessors>
<annotationProcessor>org.pf4j.processor.ExtensionAnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
</plugins>
</build>

If you place plugin items as modules in rill-flow-plugins, run quick-start will automatically pack and place plugin jar packages in the docker.

If you need to pack manually, you will get user-plugin-xxx-all.jar. You should place the jar package with a name ending in -all.jar to path /usr/local/rill_flow/plugins inside the container before it starts.