Hi Rishab,

Someone asked a similar question and I answered it on Stack Overflow [1]. The 
long and short of it is while the DBCPControllerService properties support 
expression language, they do not have access to flowfile attributes, because 
the expression language is evaluated on controller service enable, not 
per-flowfile being operated on in a processor. This is the idea behind the 
separation of concerns with controller services and processors.

If the configuration values are simply different per-environment, I would 
recommend you use the Variable Registry [2] or environment variables to hold 
those values and read them when the controller service is enabled.

If for some reason the values are different per-flowfile, I think you will need 
to explore other options (primarily, re-organizing your dataflow) as described 
in the linked answer.

[1] https://stackoverflow.com/a/49412970/70465 

Andy LoPresto
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Apr 10, 2018, at 3:45 AM, Rishab Prasad <rishabprasad...@gmail.com> wrote:
> Hi Team,
> Following are the combination of processors that I am using:-
> GetFile + SplitText + ExtractText + UpdateAttribute + ExecuteSQL +
> ConvertAvroToJson + PutFile
> Basically,I have a properties file which contains 5 comma separated values
> that are required by the 'DBCPConnectionPool' controller service to
> establish connection with the database. Here is the content of my
> properties file:-
> jdbc:mysql://localhost:3306/test,com.mysql.jdbc.Driver,C:\Program
> Files\MySQL\mysql-connector.jar,root,root
> Now, I am extracting the values from this properties file and storing them
> in manually created properties.I am using this regex to store that values
> into attributes using ExtractText.
> ExtractedData: (.*)
> Then use updateAttribute processor to manually add 5 properties and get
> their values from the properties file like below:
> connectionURL  : ${ExtractedData:getDelimitedField(1)}
> driverClass    : ${ExtractedData:getDelimitedField(2)}
> driverLocation : ${ExtractedData:getDelimitedField(3)}
> user           : ${ExtractedData:getDelimitedField(4)}
> password       : ${ExtractedData:getDelimitedField(5)}
> So, by now the attributes have got their values from the properties file
> and thus following values stored in them:
> connectionURL  : jdbc:mysql://localhost:3306/test
> driverClass    : com.mysql.jdbc.Driver
> driverLocation : C:\Program Files\MySQL\mysql-connector.jar
> user           : root
> password       : root
> Finally, Here is what I am trying to achieve. I am trying to use these
> above 5 attributes in the DBCPConnectionPool Controller Service like this:
> Database Connection URL     : ${connectionURL}
> Database Driver Class       : ${driverClass}
> Database Driver Location(s) : ${driverLocation}
> Database User               : ${user}
> Password                    : ${password}
> But I am unable to establish the connection and I am getting the error
> 'Cannot create PoolableConnectionFactory'. It seems that the controller
> service is unable to read the value from the attributes. How can I pass a
> flowfile attribute to a controller service?
> ‌

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to