Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

How do I use a custom controller service in 2 separate custom processors?

New Contributor

I have a custom controller service (nifi-cacheSinkService) created with the below structure:

 

├── nifi-cacheSinkService
│   ├── pom.xml
│   └── src
│       ├── main
│       │   ├── java
│       │   │   └── com
│       │   │       └── sample
│       │   │               └── cacheSinkService
│       │   │                   └── IgniteCacheService.java
│       │   └── resources
│       │       └── META-INF
│       │           └── services
│       │               └── org.apache.nifi.controller.ControllerService
├── nifi-cacheSinkService-api
│   ├── pom.xml
│   └── src
│       └── main
│           └── java
│               └── com
│                   └── sample
│                           └── cacheSinkService
│                               └── LocalCacheService.java
├── nifi-cacheSinkService-api-nar
│   ├── pom.xml
├── nifi-cacheSinkService-nar
│   ├── pom.xml
├── pom.xml

 

I have pushed the `nifi-cacheSinkService-api-nar` and `nifi-cacheSinkService-nar` into lib folder of nifi.

I have 2 custom processors created. One of them called nifi-transformMapper.

├── nifi-transformMapper-nar
│   ├── pom.xml
├── nifi-transformMapper-processors
│   ├── pom.xml
│   ├── src
│   │   ├── main
│   │   │   ├── java
│   │   │   │   └── com
│   │   │   │       └── sample
│   │   │   │               └── processors
│   │   │   │                   └── transformMapper
│   │   │   │                       └── TransformMapperProcessor.java
│   │   │   └── resources
│   │   │       └── META-INF
│   │   │           └── services
│   │   │               └── org.apache.nifi.processor.Processor
├── pom.xml


The processors pom has this added in dependencies:

<dependency>
	<groupId>com.sample</groupId>
	<artifactId>nifi-cacheSinkService-api</artifactId>
	<version>1.0-SNAPSHOT</version>
</dependency>



I have added a property that identifies the interface that extends my ControllerService :

	
static final PropertyDescriptor CACHE_SINK = new PropertyDescriptor.Builder()
        .name("cache-sink")
	.displayName("Cache Service")
	.description("Specifies the Controller Service to use for performing cache tasks")
	.identifiesControllerService(LocalCacheService.class).required(true).build();


Now I place my nifi-transformMapper-nar file as well inside the lib folder.

In nifi, I am able to create the controller service, but it doesn't allow me to choose that same controller service in my custom processor:

shashank_ullas_0-1641821923323.png

 

My objective is to use the same instance of the controller service in both the processors.

0 REPLIES 0