Hi,

I’m working on version 0.6.1 of Nifi (I’m not allowed to upgrade in this project) and I have to build a Custom Nifi Processor that read a specific Excel file and Write the data to Sql.

The process is working fine but I’m facing problem to configure the DBCP Controller Service Property (as I have to connect to a sql database, I want to use a connection from a Controller Service).

Looking on PutSQL Processor source code I’ve devine a ProperptyDescriptor as below:

 

public static final PropertyDescriptor ConnectionPool = new PropertyDescriptor.Builder()
        .name(
"Connection Pool")
        .description(
"JDBC Connection to Database")
        .identifiesControllerService(DBCPService.
class)
        .required(
true)
        .build()
;

 

The Property appears correctly in my Custom Processor on Nifi but when I drop down the Combobox, the list remains empty. I can create a DBCP Controller Service trough the Combobox and it appears in the list of my services, but not in the combobox (I only see the service id)

 

Did I missed something in the dependencies of my project (see Pom.xml attached)

 

I also tried this:

String connection = "ExistingDBCPControllerServiceName";
ControllerServiceLookup lookup = context.getControllerServiceLookup();
Set<String> identifiers =  lookup.getControllerServiceIdentifiers(ControllerService.class);
if
(identifiers.size()==0)log.error("No identifiers found for ControllerService");
Iterator<String> it = identifiers.iterator();
ControllerService service = null;
boolean
found = false;
while
(it.hasNext())
{

    String id = it.next()
;
   
String name = lookup.getControllerServiceName(id);
   
service = lookup.getControllerService(id);
   
log.warn(String.format("Service id: %s, name: %s, class: %s",id,name,service.getClass()));
    if
(name.equals(connection))
    {
        found=
true;
   
}
   
if(found)break;
}

 

Usting the ControllerServiceLookup and get a known ControllerService.

When I display the service class, it does not appear as DBCPService but as a com.sun.Proxy$Proxy89 class and I cannot cast the service to a DBCPService

 

If I use the code below:

try
{
    m = service.getClass().getMethod(
"getConnection",null);
   
Connection conn = (Connection) m.invoke(service,null);
   
//Cod
}
catch (NoSuchMethodException ex)
{
    log.error(
"Method getConnection not found: "+ex.getMessage());
}

 

I can retrieve the Connection from the Proxy

 

I’m not familiar coding in java (I’m a C# developer) but it seems that some dependency is missing and that my processor can’t parse processor proxy correctly

 

I’d be very grateful if you have any clue on this.

 

Thanks for your answer,

 

Mathias

 

Mathias TIBERGHIEN

CTO

Cell. : +33(0)6 27 58 13 68

  64

87 Bd Chanzy

93100 Montreuil

France

 

Tel : +33(0)1 42 87 16 57

www.code192.com

 




Avast logo

L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
www.avast.com