Reputation: 70466
I have a custom controller service that I want to use together with the ConnectWebSocket
processor. The controller service depends on nifi-websocket-services-api
and does not need a custom api (the my-customer-controller-service-api folder is empty). I have written a test for the controller service and it is passing.
However I cannot select the controller service, because ConnectWebSocket
only accepts a controller service api from nifi-websocket-service-api-nar
.
I want to avoid to recode the entire ConnectWebSocket
processor. So my question is:
Is it possible to configure the dependencies such that my custom controller service uses the api that comes from nifi-websocket-service-api-nar
?
pom.xml of controller-service:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mydomain</groupId>
<artifactId>nifi-controllerservice-bundle</artifactId>
<version>1.9.2</version>
</parent>
<artifactId>nifi-controllerservice</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- normal dependencies -->
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-processor-utils</artifactId>
<version>1.9.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-websocket-services-api</artifactId>
<version>1.9.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-websocket-services-jetty</artifactId>
<version>1.9.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-ssl-context-service-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
</dependencies>
pom.xml of controller-service-nar
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mydomain</groupId>
<artifactId>nifi-controllerservice-bundle</artifactId>
<version>1.9.2</version>
</parent>
<artifactId>nifi-controllerservice-nar</artifactId>
<version>1.9.2</version>
<packaging>nar</packaging>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<source.skip>true</source.skip>
</properties>
<dependencies>
<dependency>
<groupId>com.mydomain</groupId>
<artifactId>nifi-controllerservice</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-websocket-services-jetty</artifactId>
<version>1.9.2</version>
<scope>nar</scope>
</dependency>
</dependencies>
</project>
root pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-bundles</artifactId>
<version>1.9.2</version>
</parent>
<groupId>com.mydomain</groupId>
<artifactId>nifi-controllerservice-bundle</artifactId>
<version>1.9.2</version>
<packaging>pom</packaging>
<modules>
<module>nifi-comtom</module>
<module>nifi-comtom-nar</module>
</modules>
</project>
Upvotes: 0
Views: 548
Reputation: 18670
This should be the standard way processors and controller services work...
Processors depend on an interface which comes from the service API NAR, and controller service implementations implement that interface. The framework then knows all the implementations of that interface which allows is to provide the possible services that can be used.
Without seeing your project and poms it is hard to say what the problem is, but most likely it is a dependency issue. Your project structure should have two Maven modules, one that produces a jar for your service impl, lets call this one custom-service, and then one that packages the NAR, lets call this custom-service-nar.
The custom-service module should have a provided dependency on nifi-websocket-services-api, this allows it to compile, but we don't want to bundle that API since at runtime it will come from another NAR.
The custom-service-nar module should have a dependency of type NAR on the nifi-websocket-services-api-nar.
Upvotes: 2