luka_roves
luka_roves

Reputation: 75

Nifi artifact visibility/ dependency management

I have a two issues with dependency management.

Let's take this example:

Important note is that I want to use same instance of the CustomCacheService for both processors.

First issue is duplication of standard artifacts in GUI list of processors: Since both processors have to import a dependency to the CustomCacheService, they both need this dependency in the -nar pom.xml

<dependency>
    <groupId>org.apache.nifi</groupId>
    <artifactId>nifi-standard-services-api-nar</artifactId>
    <type>nar</type>
</dependency>
    

Without this dependency build will fail with error: Failed to create Extension Documentation Once I add this dependency, duplicates of standard nifi artifacts will be created for both processors. Bundle ids for duplicate artifact being processor groupId - artifact (com.example.processor - querycustomcache/ loadcustomcache) and version being my project version (for example: 1.0.0-SNAPSHOT) Nifi has this dependency imported all over their code and obviously not causing duplicated artifacts.

Second and more important issue is that I am not able to share CustomCacheService between processors. Once I import the service dependency to both processors and load it in nifi, in service list I will have three bundle options for this service:

Each processor expects a service instance from it's own bundle. QueryCustomCache processor expects a service instance from com.example.processor.querycustomcache and does not see any other instances. Same for LoadCustomCache processor. This makes it unable for me to use same CustomCacheService instance for both processors. I expect to be able to create CustomCacheService instance with bundle id com.example.service.customcacheservice and use it in both processors.

Both issues are tightly related. My dependencies are organized the same as in nifi source code.

Upvotes: 0

Views: 285

Answers (1)

daggett
daggett

Reputation: 28634

good explanation of your case:

https://docs.cloudera.com/HDPDocuments/HDF3/HDF-3.0.1/bk_developer-guide/content/nars.html

note the Nar-Dependency-Id element in manifest.mf

in short: in your processors you have to import interface of your service and not the implementation

Upvotes: 1

Related Questions