@shiva239
1. If you are building your own custom components for NiFi, I suppose you can have them do whatever you want. But considering your use case, you would be better off building a custom processor rather then a custom controller service. For example, building a custom version of the PutDatabaseRecord processor that instead of using a connection pool controller service, makes a a direct connection for each record.
2. I have nothing setup to test those settings, but based on setting there is still opportunity for connection reuse with multiple NiFi FlowFiles. There is the 1 sec between when one processing ends and the next may start that may grab the connection that is idling for 1 sec. Keep in mind that there is nothing in the DBCPConnectionPool code that would prevent the sever from killing closing connections at end of transaction. That is the whole purpose of the "ValidationQuery" existence. It is not common that server side closes connection. So when the DBCPConnectionPool tries to give an connection from the pool to a requesting processor, it runs the validation query to make sure the connection is still active. If validation query fails, that one is dropped from pool a new connection is made. I don't think "Max Idle Connections" is going to do anything since you set "Min idle connections" to zero which means "zero to allow no idle connections".
- Can you clarify what does -1 indicate? Does it mean no limit on the lifetime of a connection? <-- yes
The setting you have sound solid, but I would still set a validation query to ensure avoiding any chance of a race condition scenario where a 1 sec idle connection ends up getting reused that may already be a closed connection. The processor would just sit there assuming the connection was good waiting for a return. But with min idle connections set to 0, this may not be an issue. I have not tested with this specific setup ever.
Please help our community grow. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt