Apache NiFi (incubating) processors are typically organized in processor bundles. A processor bundle is generally composed of the following:
- Maven project that produces a jar containing the processors
- Maven project that packages the jar into a NAR
- Parent pom for the bundle that builds the processors and NAR
An example processor bundle from the NiFi distribution is the nifi-kafka-bundle, containing the sub-projects nifi-kafka-processors and nifi-kafka-nar.
NiFi provides a Maven archetype for easily creating this project structure. To use the archetype, run the following Maven command:
mvn archetype:generate -DarchetypeGroupId=org.apache.nifi -DarchetypeArtifactId=nifi-processor-bundle-archetype -DarchetypeVersion=0.1.0-incubating -DnifiVersion=0.1.0-incubating
The archetypeVersion corresponds to the version of the nifi-processor-bundle-archetype that is being used, currently this version is the same as the top-level NiFi version (i.e. for the NiFi 0.2.0-incubating release, the archetypeVersion would be 0.2.0-incubating, and so on). The nifiVersion is the version of NiFi that the new processors will depend on.
Running the above command will prompt you for the following properties:
Property | Description |
---|---|
groupId | The Maven groupId for the new bundle. |
artifactId | The Maven artifactId for the new bundle. Generally something like "nifi-basename-bundle", where basename is specific to your bundle. |
version | The Maven version for the new bundle. |
artifactBaseName | The base name from the artifactId. For example, to create a helloworld bundle, the artifactBaseName would be helloworld, and the artifactId would be nifi-helloworld-bundle. |
package | The Java package for the processors. |
This will create a project structure like the following:
nifi-basename-bundle├── nifi-basename-nar│ └── pom.xml├── nifi-basename-processors│ ├── pom.xml│ └── src│ ├── main│ │ ├── java│ │ │ └── org.apache.nifi.processors.basename│ │ │ └── MyProcessor.java│ │ └── resources│ │ ├── META-INF│ │ │ └── services│ │ └── org.apache.nifi.processor.Processor│ └── test│ └── java│ └── org.apache.nifi.processors.basename│ └── MyProcessorTest.java└── pom.xml
The default processor generated by the archetype is called MyProcessor. If you decide to rename this processor, make sure to also update the org.apache.nifi.processor.Processor file. This file is used by NiFi to locate available processors, and the fully qualified class name of the processor must be listed here in order for it to be available from the user interface.
By default, the newly generated bundle will inherit from the nifi-nar-bundles artifact from Apache NiFi, for the given nifiVersion that was specified. This is well suited for bundles that plan to be included with Apache NiFi, or plan to be Apache licensed, but it may not be desired in all cases. If it is preferred to not inherit from the nifi-nar-bundles artifact, then the newly generated bundle can be modified in the following ways:
- Remove the <parent>...</parent> from the bundle's root pom, or replace it with another desired parent
Add the nar plugin to bundle's root pom (ensure the latest version of the nar plugin is being used):
<build>
<plugins>
<plugin>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-maven-plugin</artifactId>
<version>1.0.1-incubating</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
- Specify the necessary dependency versions in the bundle's processors pom. This is required because the default behavior is for the dependencies to inherit their versions through the nifi-nar-bundle parent, so with a different parent these versions will have to be explicitly set.